Commit Graph

608 Commits

Author SHA1 Message Date
João Abecasis
b143a65728 Add zero-termination checks to QString and QByteArray tests
This uses an alternative approach to the testing formerly introduced
in 4ef5a626. Zero-termination tests are injected into all QCOMPARE/QTEST
invocations. This makes such testing more thorough and widespread, and
gets seamlessly extended by future tests.

It also fixes an issue uncovered by the test where using a past-the-end
position with QString::insert(pos, char), could move uninitialized data
and clobber the null-terminator.

Change-Id: I7392580245b419ee65c3ae6f261b6e851d66dd4f
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
2012-04-05 08:19:14 +02:00
João Abecasis
e1626bf038 Revert "Add tests to verify QByteArray's zero termination"
The approach used to verify for zero-termination is too intrusive and
requires additional maintenance work to ensure new zero-termination
tests are added with new functionality.

Zero-termination testing will be re-established in a subsequent commit.

This reverts commit 4ef5a6269c.

Change-Id: I862434a072f447f7f0c4bbf8f757ba216212db3c
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
2012-04-05 08:19:03 +02:00
João Abecasis
4c892e14c6 Introduce initializer macros for QString- and QByteArrayData
This enables easier updating of those structs, by reducing the amount of
code that needs to be fixed. The common (and known) use cases are
covered by the two macros being introduced in each case.

Change-Id: I44981ca9b9b034f99238a11797b30bb85471cfb7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2012-04-04 23:29:52 +02:00
João Abecasis
a959f34d71 Clean up constructors for "statics" in QString and QByteArray
There were two constuctors offering essentially the same functionality.
One taking the QStatic*Data<N> struct, the other what essentially
amounts to a pointer wrapper of that struct. The former was dropped and
the latter untemplatized and kept, as that is the most generic and
widely applicable. The template parameter in the wrapper was not very
useful as it essentially duplicated information that already maintained
in the struct, and there were no consistency checks to ensure they were
in sync.

In this case, using a wrapper is preferred over the use of naked
pointers both as a way to make explicit the transfer of ownership as
well as to avoid unintended conversions. By using the reference count
(even if only by calling deref() in the destructor), QByteArray and
QString must own their Data pointers.

Const qualification was dropped from the member variable in these
wrappers as it causes some compilers to emit warnings on the lack of
constructors, and because it isn't needed there.

To otherwise reduce noise, QStatic*Data<N> gained a member function to
directly access the const_cast'ed naked pointer. This plays nicely with
the above constructor. Its use also allows us to do further changes in
the QStatic*Data structs with fewer changes in remaining code. The
function has an assert on isStatic(), to ensure it is not inadvertently
used with data that requires ref-count operations.

With this change, the need for the private constructor taking a naked
Q*Data pointer is obviated and that was dropped too.

In updating QStringBuilder's QConcatenable specializations I noticed
they were broken (using data, instead of data()), so a test was added to
avoid this happening again in the future.

An unnecessary ref-count increment in QByteArray::clear was also
dropped.

Change-Id: I9b92fbaae726ab9807837e83d0d19812bf7db5ab
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2012-04-04 23:29:37 +02:00
Giuseppe D'Angelo
9a77171ccc QHash security fix (1.5/2): qHash two arguments overload support
Algorithmic complexity attacks against hash tables have been known
since 2003 (cf. [1, 2]), and they have been left unpatched for years
until the 2011 attacks [3] against many libraries /
(reference) implementations of programming languages.

This patch adds a qHash overload taking two arguments: the value to
be hashed, and a uint to be used as a seed for the hash function
itself (support the global QHash seed was added in a previous patch).
The seed itself is not used just yet; instead, 0 is passed.

Compatibility with the one-argument qHash(T) implementation is kept
through a catch-all template.

[1] http://www.cs.rice.edu/~scrosby/hash/CrosbyWallach_UsenixSec2003.pdf
[2] http://perldoc.perl.org/perlsec.html#Algorithmic-Complexity-Attacks
[3] http://www.ocert.org/advisories/ocert-2011-003.html

Task-number: QTBUG-23529
Change-Id: I1d0a84899476d134db455418c8043a349a7e5317
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
2012-04-04 13:02:58 +02:00
Laszlo Papp
8b56b8ed32 Add a remainingTime() method to the public interface of the QTimer class
It is an extension coming from the use case when you, for instance, need to
implement a countdown timer in client codes, and manually maintain a dedicated
variable for counting down with the help of yet another Timer. There might be
other use cases as well. The returned value is meant to be in milliseconds, as
the method documentation says, since it is reasonable, and consistent with the
rest (ie. the interval accessor).

The elapsed time is already being tracked inside the event dispatcher, thus the
effort is only exposing that for all platforms supported according to the
desired timer identifier, and propagating up to the QTimer public API. It is
done by using the QTimerInfoList class in the glib and unix dispatchers, and the
WinTimeInfo struct for the windows dispatcher.

It might be a good idea to to establish a QWinTimerInfo
(qtimerinfo_win{_p.h,cpp}) in the future for resembling the interface for
windows with the glib/unix management so that it would be consistent. That would
mean abstracting out a base class (~interface) for the timer info classes.
Something like that QAbstractTimerInfo.

Test: Build test only on (Arch)Linux, Windows and Mac. I have also run the unit
tests and they passed as well.

Change-Id: Ie37b3aff909313ebc92e511e27d029abb070f110
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
2012-04-03 15:10:05 +02:00
João Abecasis
5e82bb9e6f Introduce QArrayDataPointer::needsDetach
While QArrayDataPointer offers generic detach() functionality, this is
only useful for operations that may modify data, but don't otherwise
affect the container itself, such as non-const iteration, front() and
back().

For other modifying operations, users of the API typically need to
decide whether a detach is needed based on QArrayData's requirements
(is data mutable? is it currently shared?) and its own (do we have
spare capacity for growth?).

Now that data may be shared, static or otherwise immutable (e.g.,
fromRawData) it no longer suffices to check the ref-count for
isShared().

This commit adds needsDetach() which, from the point-of-view of
QArrayData(Pointer), answers the question: 'Can contained data and
associated metadata be changed?'.

This fixes QArrayDataPointer::setSharable for static data (e.g.,
Q_ARRAY_LITERAL), previously it only catered to shared_null.
SimpleVector is also fixed since it wasn't checking Mutability and it
needs to because it supports fromRawData().

Change-Id: I3c7f9c85c83dfd02333762852fa456208e96d5ad
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2012-04-02 16:34:21 +02:00
João Abecasis
15e3ae6b9d Introduce QArrayDataOps::truncate
This enables a truncating resize() to be implemented. It is similar to
destroyAll(), but updates the size() as it goes, so it is safe to use
outside a container's destructor (and doesn't necessarily destroy all
elements).

The appendInitialize test was repurposed and now doubles as an
additional test for QArrayDataOps as well as exercising SimpleVector's
resize().

Change-Id: Iee94a685c9ea436c6af5b1b77486734a38c49ca1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2012-04-02 16:34:21 +02:00
João Abecasis
8c413f3eff Introduce QArrayData::detachCapacity
This follows QArrayData::detachFlags's lead. Given the (known) size for
a detached container, the function helps determine capacity, ensuring
the capacityReserved flag is respected.

This further helps aggregating behaviour on detach in QArrayData itself.

SimpleVector was previously using qMax(capacity(), newSize), but there's
no reason to pin the previous capacity value if reserve() wasn't
requested. It now uses detachCapacity().

Change-Id: Ide2d99ea7ecd2cd98ae4c1aa397b4475d09c8485
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2012-04-02 16:34:21 +02:00
João Abecasis
646dc6c5da Introduce QArrayDataOps::appendInitialize
Adds given number of default-initialized elements at end of array. For
POD types, initialization is reduced to a single memset call. Other
types get default constructed in place.

As part of adding a test for the new functionality the arrayOps test was
extended to verify objects are being constructed and assigned as
desired.

Change-Id: I9fb2afe0d92667e76993313fcd370fe129d72b90
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2012-04-02 16:34:21 +02:00
Robin Burchell
47728445a5 Remove all calls to, and deprecate qMalloc, qRealloc and qFree.
Callers should just call the standard allocation functions directly.

Adding an extra function call onto all basic memory management for the sake of
making it instrumentable in rare cases isn't really fair to everyone else.

What's more, this wasn't completely reliable, as not everything was using them
in a number of places. Memory management can still be overridden using tricks
like LD_PRELOAD if needed.

Their aligned equivilents cannot be deprecated, as no standard equivilents
exist, although investigation into posix_memalign(3) is a possibility
for the future.

Change-Id: Ic5f74b14be33f8bc188fe7236c55e15c36a23fc7
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
2012-03-31 16:46:40 +02:00
João Abecasis
4ef5a6269c Add tests to verify QByteArray's zero termination
For data allocated and maintained by QByteArray, there's a guarantee
that data() is null-terminated. This holds true even for null and empty,
where logically the terminating character should never be dereferenced.

For tests that modify or generate QByteArrays, this ensures the
invariant is kept.

In the toFromHex() text, const-ness of temporary variables was dropped
to enable the test macro to be used, as the qualification didn't add
much to the test otherwise.

Change-Id: I7ee52e79e3a9df7de18c743f3698dab688e6bf0e
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
2012-03-30 11:21:34 +02:00
Thiago Macieira
ffd20af339 Revert to Qt4 behaviour that QUrl().isValid() == false
There are probably lots of places that rely on that behaviour, so go
back to what it was.

Change-Id: I4d1503a0ee105a50cdfaab52d9a5862a02c70757
Reviewed-by: David Faure <faure@kde.org>
2012-03-30 01:19:59 +02:00
Thiago Macieira
7f20dce264 Move the #include "tst_qurlinternal.moc" up to workaround a bug
I don't know if the bug is in moc or in qmake. But it bails out trying
to parse the .cpp file after the
tst_QUrlInternal::nameprep_testsuite_data function. If the #include is
placed above, it works. If it's placed below, it doesn't.

Change-Id: Ide554aa5aa3f1999e29604ba6d25ccdb09f6ef28
Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
2012-03-30 01:19:59 +02:00
Thiago Macieira
c9b78026f5 Fix the license headers for the files in the new-qurl branch
Change-Id: I469fed8b72111905e31553d0c82e62ced4009d75
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
2012-03-30 01:19:59 +02:00
Thiago Macieira
66df11f4d1 Fix QUrl operator== and operator<
Don't crash when either side is null but not both sides.

Also make sure operator< is working properly and satisfies the basic
conditions of a type (such as that if A < B, then !(B < A)).

Change-Id: Idd9e9fc593e1a7781d9f4f2b13a1024b643926fd
Reviewed-by: Giuseppe D'Angelo <dangelog@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
2012-03-30 01:19:59 +02:00
Thiago Macieira
64a10879cb Disallow spaces in URLs when parsing in StrictMode.
Change-Id: I16de68aff2b9e84cc800734c5875aaee9a2ea565
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
2012-03-30 01:19:59 +02:00
Thiago Macieira
329ee8cedc Reimplement the StrictMode URL parsing
The strict mode check is now implemented after the tolerant parser has
finished, and only if the tolerant parser has not found any errors. We
catch the use of disallowed characters (control characters plus a few
not permitted anywhere) and broken percent encodings.

We do not catch the use of Unicode characters, as they are permitted
in IRIs.

In the tests, remove the old errorString test since it makes little
sense.

Change-Id: I8261a2ccad031ad68fc6377a206e59c9db89fb38
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
2012-03-30 01:19:59 +02:00
Thiago Macieira
cff38329aa Re-introduce support for QUrl::errorString()
Note that QUrl can only remember one error. If the URL contains more
than one error condition, only the latest (in whichever parsing order
URL decides to use) will be reported.

I don't want too keep too much data in QUrlPrivate for validation, so
let's use 4 bytes only.

Change-Id: I2afbf80734d3633f41f779984ab76b3a5ba293a2
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
2012-03-30 01:19:59 +02:00
Thiago Macieira
2591545ee1 QUrl: Always lowercase the scheme
Change-Id: I8d467014d22384f1be15fdd746e20b1153a82a4e
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
2012-03-30 01:19:59 +02:00
Thiago Macieira
1372d60bde Long live the new QUrl implementation.
Also say hello to QUrl's constructor and QUrl::toString being allowed
again.

QUrl operates now on UTF-16 encoded data, where a Unicode character
matches its UTF-8 percent-encoded form (as per RFC 3987). The data may
exist in different levels of encoding, but it is always in encoded
form (a percent is always "%25"). For that reason, the previously
dangerous methods are no longer dangerous.

The QUrl parser is much more lenient now. Instead of blindly following
the grammar from RFC 3986, we try to use common-sense. Hopefully, this
will also mean the code is faster. It also operates on QStrings and,
for the common case, will not perform any memory allocations it
doesn't keep (i.e., it allocates only for the data that is stored in
QUrlPrivate).

The Null/Empty behaviour that fragments and queries had in Qt4 are now
extended to the scheme, username, password and host parts. This means
QUrl can remember the difference between "http://@example.com" and
"http://example.com".

Missing from this commit:
 - more unit tests, for the new functionality
 - the implementation of the StrictMode parser
 - errorString() support
 - normalisation

Change-Id: I6d340b19c1a11b98a48145152513ffec58fb3fe3
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
2012-03-30 01:19:59 +02:00
Thiago Macieira
1c2144c39f Forward the methods dealing with the break down of query to QUrlQuery
Now that QUrlQuery exists, these methods are no longer necessary in
QUrl itself. Manipulation of the items should be done using the new
class.

They are now implemented using a temporary QUrlQuery. This is hardly
efficient but it works.

Change-Id: I34820b3101424593d0715841a2057ac3f74d74f0
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
2012-03-30 01:19:59 +02:00
Thiago Macieira
1aeb180386 Long live QUrlQuery
This class is meant to replace the QUrl functionality that handled
key-value pairs in the query part of an URL. We therefore split the
URL parsing code from the code dealing with the pairs: QUrl now only
needs to deal with one encoded string, without knowing what it is.

Since it doesn't know how to decode the query, QUrl also becomes
limited in what it can decode. Following the letter of the RFC,
queries will not encode "gen-delims" nor "sub-delims" nor the plus
sign (+), thus allowing the most common delimiters options to remain
unchanged.

QUrlQuery has some undefined behaviour when it comes to empty query
keys. It may drop them or keep them; it may merge them, etc.

Change-Id: Ia61096fe5060b486196ffb8532e7494eff58fec1
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
2012-03-30 01:19:59 +02:00
Thiago Macieira
b75aa795fe Refactor the URL recoder a little
Change it to operate on QChar pointers, which gains a little in
performance. This also avoids unnecessary detaching in the QString
source.

In addition, make the output be appended to an existing QString. This
will be useful later when we're reconstructing a URL from its
components.

Change-Id: I7e2f64028277637bd329af5f98001ace253a50c7
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
2012-03-30 01:19:59 +02:00
Thiago Macieira
73e16b15a6 Remove the tolerant parsing function and make the recoder tolerant
The reason for this change is that the strict parser made little sense
to exist. What would the recoder do if it was passed an invalid
string?

I believe that the tolerant recoder is more efficient than the
correcting code followed by the strict recoder. This makes the recoder
more complex and probably a little less efficient, but it's better in
the common case (tolerant that doesn't need fixes) and in the worst
case (needs fixes).

Change-Id: I68a0c9fda6765de05914cbd6ba7d3cea560a7cd6
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
2012-03-30 01:19:59 +02:00
Thiago Macieira
6028efa3ff Add the code that recodes URLs.
This one function is an all-in-one:
 - UTF-8 encoder
 - UTF-8 decoder
 - percent encoder
 - percent decoder

The next step is add the ability to modify the behaviour, by telling
the function what else it must encode or decode and what it should
leave untouched.

Change-Id: I997eccfd2f9ad8487305670b18d6c806f4cf6717
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
2012-03-30 01:19:59 +02:00
Thiago Macieira
4c7e950aad Mark QUrl::{to,from}Punycode as deprecated since 5.0
These functions are now aliases to {to,from}Ace, which are usually
what you want. The original functions from Qt 4.0 had the wrong
semantics and wrong name. The new ones from Qt 4.2 execute the ACE
processing from IDNA (specifically, the ToASCII and ToUnicode
operations described in the RFC).

But so as not to be without tests, export the tests in unit testing
environment and test the punycode roundtrip. Note that the
tst_QUrl::idna_test_suite test tests *only* the Punycode roundtrip,
not the nameprepping.

Change-Id: I9b95b4bd07b4425344a5c6ef5cce7cfcb9846d3e
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: David Faure <faure@kde.org>
2012-03-30 01:19:59 +02:00
Thiago Macieira
8fa2a41bd5 Move the QByteArray-based percent-encoding activities to QByteArray
Copy the unit tests that related to percent-encoding to
tst_qbytearray.cpp and use public functions to execute
QUrl::fromPercentEncoded and QUrl::toPercentEncoded.

Change-Id: I6639ea566d82dabeb91280177a854e89e18f6f8d
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
Reviewed-by: David Faure <faure@kde.org>
2012-03-30 01:19:59 +02:00
Jędrzej Nowacki
d78fe5f8d3 Make QArrayData::shared_null zero terminated.
This is expected by QByteArray and QString

Change-Id: Ib668b144bdc0d2c793018c8f8d794f249eaf935c
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
2012-03-29 23:26:34 +02:00
Thiago Macieira
826c0723c1 Add support for IPv6 parsing and reconstructing the address
Similarly, only test against the libc function on Linux, as other OS
sometimes have different behaviour.

Change-Id: I9b8ef9a3d660a59882396d695202865ca307e528
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
2012-03-28 16:31:34 +02:00
Thiago Macieira
70db6233e7 Add a function to parse IPv4 addresses in QtCore
In the unit test, check against inet_aton on Linux with GLIBC
only. Other platforms have this function too, but they sometimes have
different behaviour, so don't try to test them equally.

Change-Id: I1a77e405ac7e713d4cf1cee03ea5ce17fb47feef
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
2012-03-28 16:31:34 +02:00
David Faure
a5a80da223 Allow auto tests to stay away from the user's configuration.
QStandardPaths now knows a "test mode" which changes writable locations
to point to test directories, in order to prevent auto tests from reading from
or writing to the current user's configuration.

This affects the locations into which test programs might write files:
GenericDataLocation, DataLocation, ConfigLocation,
GenericCacheLocation, CacheLocation.
Other locations are not affected.

Change-Id: I29606c2e74714360edd871a8c387a5c1ef7d1f54
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>
2012-03-28 11:22:11 +02:00
João Abecasis
9596f591b6 Fix loop conditions, after warnings from clang
tst_qmap.cpp:697:43: warning: inequality comparison result unused
tst_qmap.cpp:717:50: warning: inequality comparison result unused

Change-Id: I300f9e10b7748306b99c3c8c38f3cc2661a569ad
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
2012-03-28 09:36:33 +02:00
Thiago Macieira
2cf466312b Unit-test the additional QBasicAtomicXXX expansions
Test that they do expand properly and don't produce errors. This is
templated code, so it doesn't get tested fully unless we instantiate
them.

Also check that the alignments are correct.

Change-Id: I2a8ee2165167f54b652b4227411e209850974b8e
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
2012-03-28 02:16:39 +02:00
João Abecasis
2e92714090 Make QTranslator testcase independent of Widgets
There isn't really a need for the dependency as LanguageChange events can be
caught in QObject::eventFilter, directly.

Change-Id: I39778fbe1663924d97705b514ae399cfd3749776
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
2012-03-28 00:44:16 +02:00
Kent Hansen
d236fe2214 Merge master into api_changes
Conflicts:
	src/corelib/global/qisenum.h
	src/dbus/qdbusconnection_p.h
	src/widgets/kernel/qwidget.cpp
	tests/auto/other/qaccessibility/tst_qaccessibility.cpp

Change-Id: I85102515d5fec835832cc20ffdc5c1ba578bd01d
2012-03-27 19:22:48 +02:00
Lars Knoll
8660f6e385 Fix measurement system for the UK
THe UK still uses the Imperial system at least for distances
and many other things.

Change-Id: I99379de35620114328ad6a7fc9b226a46692bedd
Reviewed-by: Denis Dzyubenko <denis.dzyubenko@nokia.com>
2012-03-26 11:41:07 +02:00
Kurt Korbatits
1dc7aed0e9 Fixed qthreadstorage unittest to work from install directory
- Added install of crashonexit sub program

Change-Id: I2cc3043d5c1b879665930552487b4fe54407fd25
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2012-03-26 03:42:10 +02:00
Thiago Macieira
1904970dad Work around what apparently is a GCC 4.6.0 bug
The QFlags::operator int() isn't being called, so GCC complains that
this isn't an integer expression.

Change-Id: I537d06fd4a52ecbcddf0ef67807b298c42d3e911
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
2012-03-25 15:09:52 +02:00
João Abecasis
fe778b94bd Enable endianness conversions on q(u)int8
Lack of support for these types is not a real issue as endian
conversions on byte-sized types are no-ops. Still, the conversions are
useful as they facilitate writing of generic code. They can also be used
explicitly as a way to document in code an endian-specific binary
format:

     uchar *data;
     quint8 tag = qFromLittleEndian<quint8>(data++);
     quint32 size = qFromLittleEndian<quint32>(data);

This commit also adds a test for functions documented in the QtEndian
header.

Change-Id: I2f6c876ce89d2adb8c03a1c8a25921d225bf6f92
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2012-03-25 13:12:24 +02:00
Jędrzej Nowacki
552e162a67 Update QLocale data from CLDR v1.8.1 to CLDR v1.9.1
Change-Id: Ic84bbc82b364b92605c1bba64b6ec815bff970cb
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
2012-03-24 18:32:16 +01:00
Thiago Macieira
d8ddc8ae89 Add the Q_CORE_EXPORT macros to unit-test-exported code
Change-Id: If21658bd5e4af0fdcc403b054fc1b8f46b5fcfb0
Reviewed-by: David Faure <faure@kde.org>
2012-03-23 19:43:00 +01:00
João Abecasis
accfdc85e5 Fallback implementation of Q_ALIGNOF
For all practical purposes, the fallback introduced here returns the
desired value. Having a fallback enables unconditional use of Q_ALIGNOF.

For compilers that provide native support for it, Q_ALIGNOF is otherwise
 #defined in qcompilerdetection.h.

Change-Id: Ie148ca8936cbbf8b80fe87771a14797c39a9d30c
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2012-03-23 19:43:00 +01:00
Jędrzej Nowacki
98c3b8a442 Add test cases to tst_QByteArray
Internally we construct QByteArrays from QStaticByteArrays. For example
moc is generating QStaticByteArray structure for every string it saves.
New test cases check if a QByteArray constructed from a QStaticByteArray
behaves as a not statically constructed one.

Change-Id: Ia4aa9a1a5bc0209507636c683a782dda00eae85c
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
2012-03-23 16:43:43 +01:00
Kent Hansen
3b512ae142 Merge master into api_changes
Change-Id: I93551e4d13a1b0815b359b9415060e9089477db1
2012-03-23 14:10:58 +01:00
Giuseppe D'Angelo
1fe7e557d7 Remove #if 0 sections from QRegExp autotest
Use QEXPECT_FAIL instead (QRegExp is bugged w.r.t. the specific
test data).

Task-number: QTBUG-22466
Change-Id: Id5af01fa0d5c0536845fd4db19d4264498a8675b
Reviewed-by: hjk <qthjk@ovi.com>
Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>
2012-03-23 11:45:25 +01:00
Thiago Macieira
e20c473019 Move the UTF-8 data into a separate .cpp so I can use later
This allows me to keep the UTF-8 invalid data in one safe place. I
won't need to copy & paste it.

Change-Id: Icb909d08b7f8d0e1ffbc28e01a0ba0c1fa9dccf0
Reviewed-by: David Faure <faure@kde.org>
2012-03-23 11:22:40 +01:00
Marc Mutz
e5ef496b5b tst_qsharedpointer: don't inherit from QSharedPointer
QSharedPointer is about to be made final. Instead
of inheriting from it to gain access to the
d-pointer, cast it to a layout-compatible struct
and access the pointer from there.

Assert liberally to ensure layout compatibility.

Change-Id: Ifc0fa6a6608e861469286673844325663f4f7fcc
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2012-03-23 11:22:40 +01:00
Lars Knoll
5cb0368516 Rewrite QMap to use a RB tree
QMap used to use a skiplist in Qt 4.x, which has variable
sized nodes and we can thus not optimise using custom
allocators.

The rewrite now uses a red-black tree, and all allocations
and tree operations happen in the cpp file. This will allow
us to introduce custom allocation schemes in later versions
of Qt.

Added some more tests and a benchmark. Memory consumption
of the new QMap implementation is pretty much the same as before.
Performance of insertion and lookup has increased by 10-30%. iteration
is slower, but still extremely fast and should not matter compared
to the work usually done when iterating.

Change-Id: I8796c0e4b207d01111e2ead7ae55afb464dd88f5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2012-03-23 09:31:09 +01:00
David Faure
f89bf2c153 Make comment() work in the C locale too.
The parser makes the default language en_US, and no mimetype xml says
<comment xml:lang="C">, so use the en_US string for the C locale,
rather than returning an empty string.

Change-Id: Iad7c142e8078abe357773249416e7ce9b3e29a92
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2012-03-22 13:29:50 +01:00