profile/ivi/qtbase.git
12 years agoDon't allocate space for null when using fromRawData
João Abecasis [Wed, 4 Apr 2012 12:24:01 +0000 (14:24 +0200)]
Don't allocate space for null when using fromRawData

In this case we only need to allocate space for the "header" data.

Change-Id: I059627e47a5bae7a02c82d837c826a6ed0fd20fd
Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
12 years agoSimplify conditionals
João Abecasis [Wed, 4 Apr 2012 12:11:14 +0000 (14:11 +0200)]
Simplify conditionals

alloc >= size is an invariant of both QString and QByteArray, unless
string data is immutable (e.g., when using fromRawData()), in which case
alloc will be 0, regardless of size, That's what needs to be checked
here.

Change-Id: Ief9e6a52a1d5ea1941d23ed3c141edfd15d2a6a7
Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
12 years agoRename realloc -> reallocData
João Abecasis [Wed, 4 Apr 2012 12:04:03 +0000 (14:04 +0200)]
Rename realloc -> reallocData

This avoids confusion with standard ::realloc.

Change-Id: Ibeccf2f702ec37161033febf4f3926bee8f7aea6
Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
12 years agoMove growth computation to re-allocation function
João Abecasis [Wed, 4 Apr 2012 11:50:21 +0000 (13:50 +0200)]
Move growth computation to re-allocation function

Callers of QByteArray/QString::realloc() are still responsible for the
heuristics and decide whether to provide the "grow" hint, but
computation is centralized there.

With this change we also ensure growth takes into account the
terminating null. Previously, calls to qAllocMore took into account
header and string size, for left out the null, meaning we ended up
allocating ("nice-size" + Null).

Change-Id: Iad1536e7706cd2d446daee96859db9b01c5f9680
Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
12 years agoDrop nullary overload of private QString::realloc
João Abecasis [Wed, 4 Apr 2012 11:35:02 +0000 (13:35 +0200)]
Drop nullary overload of private QString::realloc

Change-Id: I196ec038ab7b648287e310525681f2d218059b51
Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
12 years agoIntroduce initializer macros for QString- and QByteArrayData
João Abecasis [Tue, 3 Apr 2012 11:23:55 +0000 (13:23 +0200)]
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>
12 years agoClean up constructors for "statics" in QString and QByteArray
João Abecasis [Sat, 31 Mar 2012 23:05:47 +0000 (01:05 +0200)]
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>
12 years agoDocument that the order of results from QAIM::match are not relevant.
Stephen Kelly [Thu, 22 Mar 2012 16:31:59 +0000 (17:31 +0100)]
Document that the order of results from QAIM::match are not relevant.

This will allow fixing of QTBUG-10160 in Qt 5.1.

Change-Id: I1ea7579cb4227f9940847c62d5a520c7cee3b0c5
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
12 years agoMerge one static function into another
Thiago Macieira [Fri, 30 Mar 2012 01:19:13 +0000 (22:19 -0300)]
Merge one static function into another

One static function was only being used by the other, so just merge
them and reduce the work for the compiler.

Change-Id: Ia7a1c46ace6254633450632fae7ab35816ff13bf
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
12 years agoAdd missing #include <stdio.h> for _fileno
Thiago Macieira [Tue, 3 Apr 2012 02:08:04 +0000 (23:08 -0300)]
Add missing #include <stdio.h> for _fileno

    ..\..\corelib\io\qfsfileengine_win.cpp(443) : error C3861: '_fileno': identifier not found
    ..\..\corelib\io\qfsfileengine_win.cpp(468) : error C3861: '_fileno': identifier not found
    ..\..\corelib\io\qfsfileengine_win.cpp(602) : error C3861: '_fileno': identifier not found
    ..\..\corelib\io\qfsfileengine_win.cpp(847) : error C3861: '_fileno': identifier not found
    ..\..\corelib\io\qfsfileengine_win.cpp(909) : error C3861: '_fileno': identifier not found

Change-Id: Ib6bed4814fce162e3065848c835f4774f0cbad01
Reviewed-by: Debao Zhang <dbzhang800@gmail.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
12 years agoQHash security fix (1.5/2): qHash two arguments overload support
Giuseppe D'Angelo [Sat, 24 Mar 2012 08:50:02 +0000 (08:50 +0000)]
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>
12 years agoStop relying on QHash ordering
Giuseppe D'Angelo [Sun, 1 Apr 2012 17:53:55 +0000 (18:53 +0100)]
Stop relying on QHash ordering

tst_rcc and tst_qdom rely on specific QHash orderings inside
rcc and QDom respectively (see QTBUG-25078 and QTBUG-25071).

A workaround is added to make them succeed: QDom checks for
all possible orderings, and rcc initializes the hash seed to 0
if the QT_RCC_TEST environment variable is set.

Change-Id: I5ed6b50602fceba731c797aec8dffc9cc1d6a1ce
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
12 years agoReorganize unicode string support in QString
João Abecasis [Mon, 2 Apr 2012 20:45:29 +0000 (22:45 +0200)]
Reorganize unicode string support in QString

Cleaned up preprocessor code to have a single definition for
QStaticStringData. A new qunicodechar typedef is introduced representing
a 2-byte integral type that can be used to represent a UTF-16 codepoint.

When QT_NO_UNICODE_LITERAL is not defined, QT_UNICODE_LITERAL converts a
US-ASCII string literal into a (native endian) UTF-16 string literal of
qunicodechar type.

Change-Id: I04822c4cdc0b240bc0fe113aba897348b7316932
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
12 years agoRemove the sectionAutoResize signal.
Stephen Kelly [Mon, 2 Apr 2012 14:11:42 +0000 (16:11 +0200)]
Remove the sectionAutoResize signal.

Despite being documented, it was never emitted, and I can't find
any use of it in the history either.

Change-Id: If89b401004d14ef068ada6a4099bef9dc47936c9
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
12 years agoQLocale: Merge month name data storage to save 50KB memory
John Layt [Sat, 31 Mar 2012 20:14:20 +0000 (21:14 +0100)]
QLocale: Merge month name data storage to save 50KB memory

Month Names and Standalone Month Names are stored separately, but for
majority of locales the names are the same and so storage is duplicated.
By storing both sets of names in the same array 50KB is saved in
libQtCore.so on Linux.

Depends on change Ic84bbc82 in branch api_review for CLDR 1.9.1

Change-Id: I83224ebc2180ee6de69797fa50d38348acc94107
Reviewed-by: Denis Dzyubenko <denis.dzyubenko@nokia.com>
12 years agoQHash security fix (1/2): add global QHash seed
Giuseppe D'Angelo [Sat, 24 Mar 2012 08:36:52 +0000 (08:36 +0000)]
QHash security fix (1/2): add global QHash seed

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 global integer, to be used as a seed for the hash
function itself. The seed is randomly initialized the first time a
QHash detaches from shared_null.

Right now the seed is not used at all -- another patch will modify
qHash to make use of it.

[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: I7519e4c02b9c2794d1c14079b01330eb356e9c65
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
12 years agoRemove old comment restored by mistake
Thiago Macieira [Thu, 29 Mar 2012 16:00:34 +0000 (13:00 -0300)]
Remove old comment restored by mistake

Change-Id: I1b24556110fe035c96091c5b1c5ecc00830093fc
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
12 years agoAdd a remainingTime() method to the public interface of the QTimer class
Laszlo Papp [Thu, 23 Feb 2012 05:41:30 +0000 (07:41 +0200)]
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>
12 years agoRemove duplicated template code.
Jędrzej Nowacki [Fri, 23 Mar 2012 16:14:52 +0000 (17:14 +0100)]
Remove duplicated template code.

Unify TypeDefinitions specializations. I'm not aware of any reason why
QVariant should have a separate set of supported types during
bootstrapping phase. It would cause only crashes.

As a side effect the patch reduces size of core and gui libraries.

Change-Id: I5140d9d3daee39a0171bc718bf46dab6b28085ec
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
12 years agoDon't use qstrlen if string is not null
João Abecasis [Fri, 30 Mar 2012 23:27:27 +0000 (01:27 +0200)]
Don't use qstrlen if string is not null

Change-Id: I4f9aec21af2ce24a1d27c6d140764e371bce5017
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
12 years agoQSqlDriver functions made virtual
Matt Newell [Thu, 22 Mar 2012 20:27:26 +0000 (13:27 -0700)]
QSqlDriver functions made virtual

Certain QSqlDriver functions were marked to be made virtual in Qt5.
subscribeToNotification, unsubscribeFromNotification,
subscribedToNotifications, isIdentifierEscaped, and stripDelimiters.

This patch makes them virtual and removes the no longer needed
Implementation counterpart functions. It also updates the relevant
drivers. This patch has no regressions on the tests in
tests/auto/sql/kernel/, tested with sqlite and postgres.

Change-Id: Ia2e1c18dfb803531523a456eb4e710031048e594
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
12 years agoDeprecate QItemSelectionModel::intersect().
Stephen Kelly [Mon, 2 Apr 2012 14:08:15 +0000 (16:08 +0200)]
Deprecate QItemSelectionModel::intersect().

It is already obsolete since the beginning of time (Qt 4.5).

Change-Id: Ia2f9d934f0c0bd2038d693a29d1315867a526dfe
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
12 years agoQUuid: mark as Q_PRIMITIVE_TYPE
Marc Mutz [Tue, 27 Mar 2012 08:08:12 +0000 (10:08 +0200)]
QUuid: mark as Q_PRIMITIVE_TYPE

Commit 01674860ac85a42eb152092c6e99f7ad03346977 marked
QUuid as Q_MOVABLE_TYPE, but it's even primitive:
Every bit pattern represents a valid QUuid object (if
not a valid UUID), and memcpy() can be used to obtain
a valid, independent copy of the object.

It might not be a POD, but its close enough.

Change-Id: I0fd2d11472590688a91e9ee424732e4d5ba15df8
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Denis Dzyubenko <denis.dzyubenko@nokia.com>
12 years agoIntroduce QArrayDataPointer::needsDetach
João Abecasis [Thu, 16 Feb 2012 22:28:30 +0000 (23:28 +0100)]
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>
12 years agoIntroduce QArrayDataOps::truncate
João Abecasis [Thu, 16 Feb 2012 22:27:44 +0000 (23:27 +0100)]
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>
12 years agoIntroduce QArrayData::detachCapacity
João Abecasis [Mon, 5 Mar 2012 16:43:34 +0000 (17:43 +0100)]
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>
12 years agoIntroduce QArrayDataOps::appendInitialize
João Abecasis [Thu, 16 Feb 2012 22:27:07 +0000 (23:27 +0100)]
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>
12 years agoAdd missing include on 32-bit builds
João Abecasis [Mon, 2 Apr 2012 09:39:57 +0000 (11:39 +0200)]
Add missing include on 32-bit builds

Commit cc3ff3c1 introduced uncoditional use of _BitScanForward on
Windows, so adapt include conditions to match use of function.

Change-Id: I46ea4212ea3a01d9c4ecb19377b21e9b0f16e179
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
12 years agoRemove all calls to, and deprecate qMalloc, qRealloc and qFree.
Robin Burchell [Thu, 22 Mar 2012 20:44:13 +0000 (21:44 +0100)]
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>
12 years agoMake numerus unsigned
João Abecasis [Wed, 28 Mar 2012 13:49:46 +0000 (15:49 +0200)]
Make numerus unsigned

It's the index number of the translation to be used.

Change-Id: I959c6aaa1aad09e74286d201ea356bfc4409f02a
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
12 years agoPre-validate numerus rules: fail early, fail gracefully
João Abecasis [Wed, 28 Mar 2012 13:15:10 +0000 (15:15 +0200)]
Pre-validate numerus rules: fail early, fail gracefully

Change-Id: Ibb3d27b9ff3d2f356a7c5c98b98686342f001f8f
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
12 years agoVerify presence of "magic cookie" before more expensive reads
João Abecasis [Wed, 28 Mar 2012 13:10:52 +0000 (15:10 +0200)]
Verify presence of "magic cookie" before more expensive reads

Moved this simple sanitation out of do_load as it will prevent us from
loading misplaced (or misfound) files into memory in the first place.

We'll still load anything minimally looking like a translation file.

Change-Id: Ia138be010979d4a66d330f7414fce3df20727e68
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
12 years agoAdd tests to verify QByteArray's zero termination
João Abecasis [Wed, 28 Mar 2012 22:24:50 +0000 (00:24 +0200)]
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>
12 years agoUse unsigned variable for size and index
João Abecasis [Wed, 28 Mar 2012 13:16:51 +0000 (15:16 +0200)]
Use unsigned variable for size and index

rulesSize is passed from unsigned variable numerusRulesLength, so don't
bring sign bit into equation; array index variable i also made unsigned.

Change-Id: I0cb4e8483272c1e60339298149fb118215aa2183
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
12 years agoFix comments out of touch with reality
João Abecasis [Tue, 27 Mar 2012 13:20:42 +0000 (15:20 +0200)]
Fix comments out of touch with reality

Change-Id: Id060626b0bb6c28f4e67c9b3c7a0fbc456f7dcc6
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
12 years agoRevert to Qt4 behaviour that QUrl().isValid() == false
Thiago Macieira [Thu, 29 Mar 2012 20:32:58 +0000 (17:32 -0300)]
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>
12 years agoMove the #include "tst_qurlinternal.moc" up to workaround a bug
Thiago Macieira [Thu, 29 Mar 2012 15:10:47 +0000 (12:10 -0300)]
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>
12 years agoFix the license headers for the files in the new-qurl branch
Thiago Macieira [Thu, 29 Mar 2012 14:27:10 +0000 (11:27 -0300)]
Fix the license headers for the files in the new-qurl branch

Change-Id: I469fed8b72111905e31553d0c82e62ced4009d75
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
12 years agoDe-inline qHash(const QUrl&) and improve
Thiago Macieira [Wed, 28 Mar 2012 21:11:12 +0000 (18:11 -0300)]
De-inline qHash(const QUrl&) and improve

Make it a friend and access the internals to have better performance.

Change-Id: I3bbf0b0faa5363278b7b3871d6b6fb5f2225a5f4
Reviewed-by: Giuseppe D'Angelo <dangelog@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
12 years agoFix QUrl operator== and operator<
Thiago Macieira [Wed, 28 Mar 2012 22:31:45 +0000 (19:31 -0300)]
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>
12 years agoDisallow spaces in URLs when parsing in StrictMode.
Thiago Macieira [Wed, 28 Dec 2011 18:02:44 +0000 (16:02 -0200)]
Disallow spaces in URLs when parsing in StrictMode.

Change-Id: I16de68aff2b9e84cc800734c5875aaee9a2ea565
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
12 years agoReimplement the StrictMode URL parsing
Thiago Macieira [Wed, 28 Dec 2011 17:59:47 +0000 (15:59 -0200)]
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>
12 years agoRe-introduce support for QUrl::errorString()
Thiago Macieira [Thu, 20 Oct 2011 14:23:41 +0000 (16:23 +0200)]
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>
12 years agoPort to the new QUrl API
Thiago Macieira [Thu, 13 Oct 2011 17:56:28 +0000 (19:56 +0200)]
Port to the new QUrl API

The use of any broken-down components of the query now needs
QUrlQuery.

The QUrl constructor and toString() are now rehabilitated and the
preferred forms. Use toEncoded() and fromEncoded() now only when we
need to store data in a QByteArray or the data comes from a QByteArray
anyway. Change to toString() or the constructor if the data was in a
QString.

Change-Id: I9d761a628bef9c70185a48e927a61779a1642342
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
12 years agoAdd QUrl::setQuery overload with QUrlQuery
Thiago Macieira [Wed, 19 Oct 2011 23:23:14 +0000 (01:23 +0200)]
Add QUrl::setQuery overload with QUrlQuery

Change-Id: I0cba92b6bf7f848f1918383b380c0444b8bead3a
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
12 years agoQUrl: optimise setHost for the common case
Thiago Macieira [Wed, 19 Oct 2011 18:33:31 +0000 (20:33 +0200)]
QUrl: optimise setHost for the common case

Change-Id: Ib667557268ebf75cb796ddd716b337ca24b466ad
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
12 years agoQUrl: Always lowercase the scheme
Thiago Macieira [Wed, 19 Oct 2011 18:31:46 +0000 (20:31 +0200)]
QUrl: Always lowercase the scheme

Change-Id: I8d467014d22384f1be15fdd746e20b1153a82a4e
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
12 years agoLong live the new QUrl implementation.
Thiago Macieira [Thu, 8 Sep 2011 20:06:17 +0000 (22:06 +0200)]
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>
12 years agoMove some of qurl.cpp into other files for ease of maintenance
Thiago Macieira [Thu, 8 Sep 2011 19:58:50 +0000 (21:58 +0200)]
Move some of qurl.cpp into other files for ease of maintenance

The parsing code is now in qurlparser.cpp, whereas the IDNA related
code is in qurlidna.cpp.

Change-Id: I0b32c0bf0ee6c2f08dc3200c44af3c9d1504a3df
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
12 years agoForward the methods dealing with the break down of query to QUrlQuery
Thiago Macieira [Thu, 8 Sep 2011 20:05:42 +0000 (22:05 +0200)]
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>
12 years agoLong live QUrlQuery
Thiago Macieira [Sat, 3 Sep 2011 13:05:56 +0000 (15:05 +0200)]
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>
12 years agoRefactor the URL recoder a little
Thiago Macieira [Thu, 8 Sep 2011 15:40:36 +0000 (17:40 +0200)]
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>
12 years agoRemove the tolerant parsing function and make the recoder tolerant
Thiago Macieira [Tue, 6 Sep 2011 18:36:28 +0000 (20:36 +0200)]
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>
12 years agoAdd the code that recodes URLs.
Thiago Macieira [Mon, 5 Sep 2011 21:17:21 +0000 (23:17 +0200)]
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>
12 years agoMark QUrl::{to,from}Punycode as deprecated since 5.0
Thiago Macieira [Fri, 2 Sep 2011 18:43:50 +0000 (20:43 +0200)]
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>
12 years agoMove the QByteArray-based percent-encoding activities to QByteArray
Thiago Macieira [Fri, 2 Sep 2011 18:09:35 +0000 (20:09 +0200)]
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>
12 years agoMake QArrayData::shared_null zero terminated.
Jędrzej Nowacki [Tue, 27 Mar 2012 10:27:54 +0000 (12:27 +0200)]
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>
12 years agoRemove compression support from moc.
Jędrzej Nowacki [Tue, 27 Mar 2012 10:30:50 +0000 (12:30 +0200)]
Remove compression support from moc.

Moc doesn't compress anything so it doesn't have to link against zlib.
In practice it is a build fix for a bug exposed by previous patches.

Change-Id: I0debfccc903b3addd7c16be8421a51b6be9ceb2f
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
12 years agoAdd an assert to QMetaObjectBuilder.
Jędrzej Nowacki [Tue, 27 Mar 2012 12:23:38 +0000 (14:23 +0200)]
Add an assert to QMetaObjectBuilder.

Constructors and destructors don't have a return value, but every other
method return at least "void".

Change-Id: Ie621aff83e44c187e950910d5c0684ba1a6579b8
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
12 years agoCompile QArrayData in bootstrap phase.
Jędrzej Nowacki [Tue, 27 Mar 2012 09:21:27 +0000 (11:21 +0200)]
Compile QArrayData in bootstrap phase.

This change will be needed during migration from QByteArrayData to
QArrayData.

Change-Id: I0c8d6f9ed3ef7c33af62736af55259a8f9a70c0f
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
12 years agoFix operator precedence order.
Thiago Macieira [Thu, 29 Mar 2012 00:03:38 +0000 (21:03 -0300)]
Fix operator precedence order.

Clang (I guess it was clang) reports:

io/qipaddress.cpp:276:34: warning: operator '?:' has lower precedence than '+'; '+' will be evaluated first [-Wparentheses]

Fix the precedence by wrapping the ternary expression in parentheses.

Change-Id: I1c995dc8e2b1b831480ea8f8a695f7f89c08fcac
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
12 years agoMake qsimd.cpp also complain if required features are missing
Thiago Macieira [Sat, 31 Dec 2011 02:16:13 +0000 (00:16 -0200)]
Make qsimd.cpp also complain if required features are missing

Record in a variable the features that the compiler used for code
generation when Qt was compiled. Then complain if those are
missing. This is required in qdrawhelper_plain.cpp to make it disable
the plain build, keeping only the AVX, Neon or SSE2 builds. This code
works for GCC, ICC on Unix and Clang.

MSVC support is pending. It will involve defining the same macros
from qsimd_p.h when the compiler support is detected.

Other compilers are unknown. The only relevant one would be Sun Studio
for x86, but I have no access to it to find out what macros it
predefines.

Change-Id: I25f2d90b3c7ac7bd0442f4b349b6ee3bd751a95b
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
12 years agoClean up and make robust the file loading code
João Abecasis [Tue, 27 Mar 2012 15:32:43 +0000 (17:32 +0200)]
Clean up and make robust the file loading code

The used_mmap variable was set to true the first time an mmap operation
was successful, but it was never reset back to false. While that can be
a good indicator that future calls might succeed it is not a guarantee.
Not properly resetting could mean we'd unmap memory allocated with new,
instead of deleting it.

Since that variable is only used inside defined(QT_USE_MMAP) blocks, its
declaration is scoped the same way.

While mmap is still handled "by hand", use QFile for the other
operations. Calling mmap here is less than ideal, as it prevents use of
other memory mapping methods, such as native Windows APIs, but is less
intrusive as it allows QTranslator to retain control over lifetime of
the map. Using QFile for remaining operations reduces the number of
filesystem operations.

The file size is now checked to be minimally sane (<4GB), the limit of
the 32-bit variable that will hold mapping's length. Translation files
should be expected to be much smaller in practice, but there isn't a
sane hard-limit. The file format is broken down to sections, each of
which has a 32-bit length.

Finally, when loading a file fails, release resources immediately,
instead of delaying to next load attempt or the destructor.

Change-Id: I5cc1b626a99d229e8861eb0fbafc42b928b6a122
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
12 years agoPort QHostAddress to use the new IP utilities in QtCore
Thiago Macieira [Mon, 17 Oct 2011 11:41:19 +0000 (13:41 +0200)]
Port QHostAddress to use the new IP utilities in QtCore

The new code now generates lowercase hex instead of uppercase, so
adapt the unit tests to pass.

Also, "123.0.0" is now considered valid (compatibility with inet_aton).

Change-Id: I07b5125abf60106dc5e706033d60836fb690a41f
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
12 years agoAdd support for IPv6 parsing and reconstructing the address
Thiago Macieira [Fri, 14 Oct 2011 15:12:34 +0000 (17:12 +0200)]
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>
12 years agoAdd a function to parse IPv4 addresses in QtCore
Thiago Macieira [Thu, 13 Oct 2011 20:49:19 +0000 (22:49 +0200)]
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>
12 years agoRemove the -no-stl option from configure
Thiago Macieira [Mon, 26 Mar 2012 17:57:40 +0000 (14:57 -0300)]
Remove the -no-stl option from configure

This was decided on the mailing list. See:
http://lists.qt-project.org/pipermail/development/2012-March/002442.html
http://lists.qt-project.org/pipermail/development/2012-March/002465.html

Change-Id: I7681e5cc743b20f6d4e29d2aea45c50df41a0b98
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
12 years agoRemove the old code using MMX registers.
Thiago Macieira [Thu, 29 Dec 2011 20:09:46 +0000 (18:09 -0200)]
Remove the old code using MMX registers.

There are only 8 MMX registers, each 64-bit wide, and they alias the
x87 registers. The access to the MMX register cannot use the new
VEX-prefix instructions either.

All of the functions being replaced are either present in the
qdrawhelper_sse2.cpp and qdrawhelper_ssse3.cpp files, or the plain C++
function in qdrawhelper.cpp is vectorised when compiled with
-ftree-vectorize (enabled in -O3), if SSE2 support is enabled.

All x86-64 processors have SSE2, so this is a net improvement for
64-bit builds. For 32-bit builds, without further support this will
cause the code to use non-vector or x87 instructions, which aren't the
best. The solution will come in another commit.

Change-Id: I4a22d8a2516b79172867510202d0fd627db54807
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
12 years agoRemove WA_PaintOutsidePaintEvent
Debao Zhang [Sat, 24 Mar 2012 01:19:27 +0000 (18:19 -0700)]
Remove WA_PaintOutsidePaintEvent

WA_PaintOutsidePaintEvent is only suggested to be used when porting Qt3 code
to Qt 4 under X11 platform. and it has been broken now.

Change-Id: Ie4297b2a449f1055ca10ada9efb930e6018b1efb
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
12 years agoRemove AutoCompatConnection
Debao Zhang [Fri, 23 Mar 2012 21:43:07 +0000 (14:43 -0700)]
Remove AutoCompatConnection

The default type when Qt 3 support is enabled. Same as
AutoConnection but will also cause warnings to be output in
certain situations.

Change-Id: I64bf3c39a740afb716820bfd3173936fda213f4a
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
12 years agoAllow auto tests to stay away from the user's configuration.
David Faure [Sun, 25 Mar 2012 11:10:48 +0000 (13:10 +0200)]
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>
12 years agoEnsure QTypedArrayData is just a shim over QArrayData
João Abecasis [Tue, 27 Mar 2012 10:49:00 +0000 (12:49 +0200)]
Ensure QTypedArrayData is just a shim over QArrayData

Change-Id: I6f41ca054d0e0a0c4642f0b841b3b3df9559f818
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
12 years agoImprove output on test failures
João Abecasis [Thu, 22 Mar 2012 00:28:30 +0000 (01:28 +0100)]
Improve output on test failures

This adds checks to ensure Q_ALIGNOF is returning the desired alignment
for explicitly-aligned types.

The alignment check is now inlined in the test inside QCOMPARE so we get
slightly more informative errors:

FAIL!  : tst_Collections::alignment() Compared values are not the same
   Actual   (quintptr(&it.value()) % Value::PreferredAlignment): 64
   Expected (quintptr(0)): 0
   Loc: [tst_collections.cpp(3384)]

In this case, this is enough to notice "non-native" alignments are being
requested. Having test parameters otherwise hidden in template arguments
doesn't help the situation.

Change-Id: I05267fd25b71f183cfb98fb5b0a7dfd6c28da816
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
12 years agoSilence unused comparison result warnings (clang)
João Abecasis [Thu, 22 Mar 2012 00:22:41 +0000 (01:22 +0100)]
Silence unused comparison result warnings (clang)

The intent is to force instantiation of template container classes and
semantics or behaviour are otherwise irrelevant in this context.

tst_collections.cpp:3036:15: warning: inequality comparison result unused
tst_collections.cpp:3037:15: warning: equality comparison result unused
tst_collections.cpp:3100:15: warning: inequality comparison result unused
tst_collections.cpp:3101:15: warning: equality comparison result unused

Change-Id: I70ad38b18dcbc43879e36a34b1da460aee5f7b07
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
12 years agoFix loop conditions, after warnings from clang
João Abecasis [Thu, 22 Mar 2012 00:19:34 +0000 (01:19 +0100)]
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>
12 years agoDon't hardcode the order of elements in QHashes
Thiago Macieira [Tue, 27 Mar 2012 15:14:14 +0000 (12:14 -0300)]
Don't hardcode the order of elements in QHashes

Instead use QMap if we want a stable order.

Task-number: QTBUG-24995
Change-Id: I93f643df236f5078768f539615fa47163e5262e8
Reviewed-by: Giuseppe D'Angelo <dangelog@gmail.com>
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
12 years agoUnit-test the additional QBasicAtomicXXX expansions
Thiago Macieira [Sun, 31 Jul 2011 22:41:18 +0000 (19:41 -0300)]
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>
12 years agoRemove workaround for QComboBox not having a USER property.
Stephen Kelly [Wed, 21 Mar 2012 19:42:50 +0000 (20:42 +0100)]
Remove workaround for QComboBox not having a USER property.

QComboBox does in fact have a user property
since b1b87a73012342dc1619a8e907ea9954d59ca564.

Change-Id: I24eb2ef267cec5d8a9f7348954b703fa6df04fa5
Reviewed-by: Girish Ramakrishnan <girish.1.ramakrishnan@nokia.com>
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
Reviewed-by: David Faure <faure@kde.org>
12 years agoAdd USER properties to QDateEdit and QTimeEdit.
Stephen Kelly [Wed, 21 Mar 2012 19:41:57 +0000 (20:41 +0100)]
Add USER properties to QDateEdit and QTimeEdit.

Both classes had such components before, but there were issues with
the NOTIFY signal not being in the same class as the Q_PROPERTY.

This patch solves that problem by using a signal of a different name.

Task-number: QTBUG-15731
Change-Id: Ibc7ce4dba8a6b88c05d62a90e14d0101c5cd3082
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
12 years agoUnify the atomic implementation for x86 architectures
Thiago Macieira [Mon, 27 Feb 2012 15:01:53 +0000 (16:01 +0100)]
Unify the atomic implementation for x86 architectures

It's almost exactly the same code in both files, so let's have one file
only. That means we need an #ifdef for the special case of 64-bit types
on i386.

Also take the opportunity to add a comment explaining how this works.

Change-Id: I50d274fa026806ae511b1045aa8a5c25daaa0edc
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
12 years agoRename qatomic_x86_64.h to qatomic_x86.h
Thiago Macieira [Mon, 27 Feb 2012 14:32:47 +0000 (15:32 +0100)]
Rename qatomic_x86_64.h to qatomic_x86.h

This is the first step in merging the i386 and x86-64
architectures. The next commit will bring i386 support into
qatomic_x86.h.

Change-Id: I24105ea70f3fc29b3fb779a70053f99117440573
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
12 years agoFail when no translations found, reset pointers on failure
João Abecasis [Tue, 27 Mar 2012 13:26:19 +0000 (15:26 +0200)]
Fail when no translations found, reset pointers on failure

We don't want to be using or trusting partial loads.

Change-Id: I3934d6cf54cd99eaab2fa7aee9a0e9968d9f3c13
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
12 years agoUse Big-Endian conversion functions from qendian.h
João Abecasis [Tue, 27 Mar 2012 11:18:03 +0000 (13:18 +0200)]
Use Big-Endian conversion functions from qendian.h

These avoids repeating code and documents that the underlying format is
compacted big-endian.

Change-Id: I5a2dc0084945d99368183203a0a9b7c116874620
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
12 years agoRemove unused argument
João Abecasis [Tue, 27 Mar 2012 11:07:10 +0000 (13:07 +0200)]
Remove unused argument

The mode argument (third argument to (_)open) is only used when
(_)O_CREAT is also specified. As we're opening the file read-only it is
unused and unnecessary.

Change-Id: Icc16edec5a7d44c57ad02865048c56114c39d4bc
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
12 years agoThere's no need to check pre-validated input
João Abecasis [Tue, 27 Mar 2012 11:01:28 +0000 (13:01 +0200)]
There's no need to check pre-validated input

elfHash and friends are used solely from do_translate, which already
checks for null strings. There's no need to do it again here.

Change-Id: I90a16d2623ca753a444e53952539001988568bdb
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
12 years agoUse accumulating hash, instead of allocating intermediate string
João Abecasis [Tue, 27 Mar 2012 10:59:24 +0000 (12:59 +0200)]
Use accumulating hash, instead of allocating intermediate string

Change-Id: Ie93ac8df3066159ad11ff7f68c7ba85e7f5aa8bc
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
12 years agoMake QTranslator testcase independent of Widgets
João Abecasis [Thu, 22 Mar 2012 00:38:48 +0000 (01:38 +0100)]
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>
12 years agoAvoid overflow in boundary check
João Abecasis [Tue, 27 Mar 2012 16:08:09 +0000 (18:08 +0200)]
Avoid overflow in boundary check

Change-Id: I4f397795a65d5d6ea237a6751588a8dc6be15bdc
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
12 years agoMerge master into api_changes
Kent Hansen [Tue, 27 Mar 2012 14:19:29 +0000 (16:19 +0200)]
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

12 years agoDisable ICC diagnostic 2261 about __assume with side-effects
Thiago Macieira [Mon, 26 Mar 2012 13:37:06 +0000 (10:37 -0300)]
Disable ICC diagnostic 2261 about __assume with side-effects

The warning is presented now that we use __assume in every
Q_ASSERT. It presents itself in code that calls functions, like:

tools/qbitarray.h(128): warning #2261: __assume expression with side effects discarded
  { Q_ASSERT(i >= 0 && i < size());
    ^

Change-Id: I5851b3c35b56c00b9c541c2489233121ef621e04
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
12 years agodevice: Add -device and -device-option to configure
Girish Ramakrishnan [Tue, 20 Mar 2012 21:02:21 +0000 (14:02 -0700)]
device: Add -device and -device-option to configure

For some reference platforms and SDKs we will need to pass in
extra paths. Currently users have to modify the mkspec to adjust
paths or set environment variables that will be picked up.

This change introduces the -device <name> and -device-option
<key=value> option. The key value pairs will be written to a
qdevice.pri and can be used by the qmake.conf of the device spec.

The reason to not save the key value pairs in qconfig.pri is
becase of the fact that the device spec loads the qdevice.pri
earlier than the qconfig.pri. qdevice.pri allows the mkspec
to set the compiler flags and qconfig.pri allows configure to
add to those compiler flags.

Done-with: Holger Freyther

Change-Id: I931a197b8be72397e1eedfee09502eefc01c9d4f
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Reviewed-by: Girish Ramakrishnan <girish.1.ramakrishnan@nokia.com>
Reviewed-by: Johannes Zellner <johannes.zellner@nokia.com>
Reviewed-by: Donald Carr <donald.carr@nokia.com>
12 years agoMark tst_qdialog as insignificant on mac.
Rohan McGovern [Mon, 26 Mar 2012 23:34:48 +0000 (09:34 +1000)]
Mark tst_qdialog as insignificant on mac.

This autotest gives different results on consecutive runs, and is
therefore insignificant for the purpose of detecting regressions.

Task-number: QTBUG-24977
Change-Id: I5c4dfd663ce5df6b60ae47a29d332c06e3c0585f
Reviewed-by: Kalle Lehtonen <kalle.ju.lehtonen@nokia.com>
12 years agoSync configure with Unix version (-make/-nomake)
Marius Storm-Olsen [Wed, 21 Mar 2012 10:09:59 +0000 (11:09 +0100)]
Sync configure with Unix version (-make/-nomake)

Move previous -make <exe> feature to -make-tool <exe>

Change-Id: I1cbc87e60e2588fd8b2a11c11178988003cac7c1
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
12 years agoMake QWidget::mapTo/mapFrom() take const pointers.
Jason McDonald [Mon, 26 Mar 2012 09:59:56 +0000 (19:59 +1000)]
Make QWidget::mapTo/mapFrom() take const pointers.

This commit addresses a long-standing Qt 5 to-do. Whilst a trivial
change, it is binary incompatible.

Task-number: QTBUG-665
Change-Id: I4294233d876dec79eda57113bdf298ce73643e76
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
12 years agoMake QWidget::isEnabledTo() and isVisibleTo() to take const pointers.
Jason McDonald [Mon, 26 Mar 2012 09:09:49 +0000 (19:09 +1000)]
Make QWidget::isEnabledTo() and isVisibleTo() to take const pointers.

This commit addresses a long-standing Qt 5 to-do comment. Whilst a
trivial change, it is binary incompatible.

Task-number: QTBUG-259

Change-Id: I2fc7bfda488318dbabbbea9f5ff9d2b1d6ce0784
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
12 years agoMake QGridLayout::getItemPosition() const.
Jason McDonald [Mon, 26 Mar 2012 15:05:41 +0000 (01:05 +1000)]
Make QGridLayout::getItemPosition() const.

This commit addresses a long-standing Qt 5 to-do. Whilst a trivial
change, it is binary incompatible.

Task-number: QTBUG-1433
Change-Id: I6e31e47fd5791cb6f1373e2696ffc95f7174f0b0
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
12 years agoAdd support for detecting SSE2 and SSE3 on WinCE
Thiago Macieira [Thu, 22 Mar 2012 22:34:41 +0000 (19:34 -0300)]
Add support for detecting SSE2 and SSE3 on WinCE

Change-Id: Ic26ba2073d1f1d7e12338811b86f9b99ea8f1eac
Reviewed-by: Andreas Holzammer <andreas.holzammer@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
12 years agoCocoa: initialize QCocoaEventDispacherPrivate::lastSerial
Bradley T. Hughes [Mon, 26 Mar 2012 09:58:01 +0000 (11:58 +0200)]
Cocoa: initialize QCocoaEventDispacherPrivate::lastSerial

This silences warnings from valgrind about a conditional depending on an
uninitialized value.

Change-Id: I819a44ed5dc02e163c00849811870c94f66b6651
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
12 years agoUse ADD/SUB instructions on x86 and x86-64 atomics instead of INC/DEC
Thiago Macieira [Sun, 25 Dec 2011 21:30:15 +0000 (19:30 -0200)]
Use ADD/SUB instructions on x86 and x86-64 atomics instead of INC/DEC

According to the Intel Optimization Manual section 3.5.1.1 Use of INC
and DEC Instructions, those instructions modify only part of the flags
register, so they mey introduce unnecessary data dependencies on
previous flag-setting operations so that the resulting flags are
computed. Preferring ADD and SUB (rule 33) is recommended.

However, we don't do it for 16-bit integers. The reason is that the
presence of the 0x66 prefix may trigger a slower decoding codepath in
the processor (up to 6 cycles, as opposed to 1). The same Intel manual
talks about Length-Changing Prefix, which applies in particular to
instructions with 16-bit immediates. The assembler generally produces
uses the 8-bit immediate variant of the ADD and SUB instructions, but
to be on the safe side, we prefer to use INC and DEC here.

Change-Id: Ic03236ac600a5b4e087614d21df5d3c666ae064e
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
12 years agoFix the 64-bit i386 atomic according to assembly output
Thiago Macieira [Sun, 8 Jan 2012 22:45:11 +0000 (20:45 -0200)]
Fix the 64-bit i386 atomic according to assembly output

The assembly output showed that GCC was generating some wrong code in
some conditions, so update the constraints so it will do the right
thing: the expectedValue constraint needs to be in/out with early
clobber. In/out because cmpxchg8b really does produce output and, even
if we don't care about it, GCC needs to be told that the registers
used (EAX:EDX) were modified. The early clobber is necessary so it
won't schedule EAX or EDX to be the same as the EBX_reg (the register
we'll xchg EBX with).

Since EAX and EDX are in/out and EBX can't be used, the only remaining
low register for the "sete" instruction is CL. So use it directly and
set ECX to be in/out too.

For whatever reason, it can't find enough registers in debug mode and
this expansion doesn't work. It looks like a bug though, since this
requires 4 registers and one memory operand and in debug mode it must
have EAX, ECX, EDX, ESI and EDI free for use. One of ESI or EDI is
used to xchg EBX with, which means there must be at least one more
free general register.

Change-Id: I1f11e68d776bf9ad216b34ca316a53129122fabe
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>