profile/ivi/qtbase.git
12 years agoQHash security fix (2/2): enable QHash random seed
Giuseppe D'Angelo [Sat, 24 Mar 2012 08:50:02 +0000 (08:50 +0000)]
QHash security fix (2/2): enable QHash random 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 makes qHash use the QHash seed introduced in the
previous commits, thus truly randomizing bucketing in QHash.

[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: Ibee9cf6aa820af5d777fcde478647665c728052a
Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>
12 years agoQHash: remove optimization for QHash<int, T>
Giuseppe D'Angelo [Fri, 13 Apr 2012 17:59:58 +0000 (18:59 +0100)]
QHash: remove optimization for QHash<int, T>

QHash employs an optimization for int/uints, squashing the hash
value and the key value inside an union. This obviously works
iff qHash(int k) = k. If the hash value gets salted, the hash
table is corrupted.

This patch removes that optimization by means of a #if 0,
so if further research finds out that we want those 4 bytes back
it's pretty simple to revert.

Change-Id: If273f0bf2ff007f4f2f7c46d2aab364a3b455cf1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
12 years agoQHash: fix key() test
Giuseppe D'Angelo [Fri, 13 Apr 2012 18:41:47 +0000 (19:41 +0100)]
QHash: fix key() test

The key returned by QHash::key is an arbitrary one that maps to the
given value. The test instead relied on it being a specific one.

Change-Id: I090351797e8b52036d78160fd810518a11e8107d
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
12 years agoqHash: qHash(T*) two arguments support
Giuseppe D'Angelo [Tue, 10 Apr 2012 20:28:10 +0000 (21:28 +0100)]
qHash: qHash(T*) two arguments support

Change-Id: I1b78914fe9c6ee9251d68af1f2e95f1e3e0f1db5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
12 years agoqHash: two arguments support for simple integer types (and QChar)
Giuseppe D'Angelo [Fri, 13 Apr 2012 18:01:16 +0000 (19:01 +0100)]
qHash: two arguments support for simple integer types (and QChar)

Change-Id: I24bed73422fb1d2e90cf3dd4e5375e249b3dcac4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
12 years agoRemoved QXmlStreamReader::readElementText overload
Thorbjørn Lindeijer [Thu, 12 Apr 2012 20:21:56 +0000 (22:21 +0200)]
Removed QXmlStreamReader::readElementText overload

The version without argument was kept for binary compatibility when
the configurable ReadElementTextBehaviour was introduced. It is now
dropped in favour of using a default argument value.

Change-Id: Ic08c41d5a5aad9f22df7fc37a2d53ffbc6df1fe9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
12 years agoQSharedPointer: hash autotest fix
Giuseppe D'Angelo [Mon, 9 Apr 2012 18:14:31 +0000 (19:14 +0100)]
QSharedPointer: hash autotest fix

The hash autotest is wrong: it assumed that the iterator on the hash
would reach the end after iterating on two elements with identical key.
But three elements were added to that hash, and the third one
can appear after the other two.

That code path is left for the map test only.

Change-Id: I51de7987e2b132b6caff7bb4bac6a57fb7fcb530
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
12 years agoQSharedPointer: qHash two arguments support
Giuseppe D'Angelo [Tue, 10 Apr 2012 23:40:36 +0000 (00:40 +0100)]
QSharedPointer: qHash two arguments support

Change-Id: I800de3fd9769e4829018360c25a8cf2ee2e2e08b
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
12 years agoAdd unit test for BackgroundRequestAttribute
Shane Kearns [Tue, 10 Apr 2012 12:14:51 +0000 (13:14 +0100)]
Add unit test for BackgroundRequestAttribute

Change-Id: I807953cac3d23825461f9ae860badbd148835330
Reviewed-by: Martin Petersson <Martin.Petersson@nokia.com>
12 years agoQLayoutItem - make controlTypes a virtual function.
Thorbjørn Lund Martsum [Fri, 16 Mar 2012 06:00:45 +0000 (07:00 +0100)]
QLayoutItem - make controlTypes a virtual function.

Just implementing the ### Qt5 suggestion about making
controlTypes a virtual function.

Change-Id: Ic1db47fe488f089de965438e456e9b48e0b96f32
Reviewed-by: Girish Ramakrishnan <girish.1.ramakrishnan@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
12 years agoStyle: Don't put an else after a return.
Stephen Kelly [Sun, 1 Apr 2012 18:25:33 +0000 (20:25 +0200)]
Style: Don't put an else after a return.

Change-Id: I41d031d92489e5539f293c30a6257310f2a1c657
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
12 years agoRe-add the Qt 4 compatibility methods for QUrl encoded query items
Thiago Macieira [Thu, 12 Apr 2012 16:36:23 +0000 (13:36 -0300)]
Re-add the Qt 4 compatibility methods for QUrl encoded query items

I forgot to re-add those when I re-added the non-encoded (QString)
forms.

Change-Id: I9d635d40106273177df2c332f09d66415efc15a3
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
12 years agoEnsure proper handling of empty-but-present URL components
Thiago Macieira [Wed, 11 Apr 2012 20:55:18 +0000 (17:55 -0300)]
Ensure proper handling of empty-but-present URL components

The new QUrl is able to distinguish a URL component that is empty from
one that is absent. The previous one already had that capability for
the port, fragment and query, and the new one extends that to the username,
password and path. The path did not need this handling because its
delimiter from the authority it part of the path.

For example, a URL with no username is one where it's set to QString()
(null). A URL like "http://:kde@kde.org" is understood as an
empty-but-present username, for which toString(RemovePassword) will
return "http://@kde.org", keeping the empty-but-present username.

Change-Id: I2d97a7656f3f1099e3cf400b199e68e4c480d924
Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
12 years agoRemove QPaintBufferSignalProxy and QPaintBufferResource.
Robin Burchell [Thu, 12 Apr 2012 11:37:43 +0000 (13:37 +0200)]
Remove QPaintBufferSignalProxy and QPaintBufferResource.

Nothing seems to use these...

Change-Id: I58b3e5f8536e43b3076da0a86d9093a6e11b947a
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
12 years agoRemove 'using' of QPaintEngineEx methods from QRasterPaintEngine.
Robin Burchell [Thu, 12 Apr 2012 07:06:16 +0000 (09:06 +0200)]
Remove 'using' of QPaintEngineEx methods from QRasterPaintEngine.

drawEllipse() and the drawPolygon() overloads are all reimplemented, so there is
no point having this here.

Change-Id: I343cea0dd0fff2ed6a27be2a19459056e929f9d8
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
12 years agoRemove unused QIntRect.
Robin Burchell [Wed, 11 Apr 2012 08:21:05 +0000 (10:21 +0200)]
Remove unused QIntRect.

I can't find any uses of this anywhere, in either Qt 4 or Qt 5.

Change-Id: Ibf747b57b4afdd81e11631e87a80dcab5ac12f69
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
12 years agoAddress Qt 5 to-do comments related to QFileSystemModel.
Jason McDonald [Wed, 11 Apr 2012 12:52:21 +0000 (22:52 +1000)]
Address Qt 5 to-do comments related to QFileSystemModel.

- QFileSystemModel::rmdir() and QFileSystemModel::remove() changed to
  non-const -- they don't change the object, but they do change the
  file system, and the Qt way is to be non-const if having side-effects
  on external entities.
- The comment on incompatibility between entryList and QFileInfo will
  not be fixed as doing so is likely to break existing code.
- The comment on removing the internal resolvedSymLinks variable has
  been removed, as the variable is still used.

Task-number: QTBUG-25088
Change-Id: I20456e4d116076403d9c4d4692ee05c178a1ed17
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
12 years agoAddress Qt 5 to-do comment for QColorDialog.
Jason McDonald [Wed, 11 Apr 2012 12:22:26 +0000 (22:22 +1000)]
Address Qt 5 to-do comment for QColorDialog.

- change customColor() to return QColor instead of QRgb.
- change setCustomColor() and setStandardColor() to take
  a QColor instead of QRgb.
- add missing standardColor() getter method.

Task-number: QTBUG-25087
Change-Id: Ic6adb2031ef47f5e9b15fa3560a5322e6847c0bb
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
12 years agomake QStringList::sort() to take a Qt::CaseSensitivity param
Konstantin Ritt [Wed, 11 Apr 2012 15:06:11 +0000 (18:06 +0300)]
make QStringList::sort() to take a Qt::CaseSensitivity param

Task-number: QTBUG-12892

Change-Id: I402e6fb12ff24ac26c5a8103bf81547946f9cc58
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
12 years agoFix warning introduced in "Adjust a double leading slash..."
Thiago Macieira [Wed, 11 Apr 2012 20:58:55 +0000 (17:58 -0300)]
Fix warning introduced in "Adjust a double leading slash..."

Change-Id: Id89fd3983123c0ba302c493b54437dd75e419e01
Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
12 years agoMake QBoxLayout::insertItem() public.
Jason McDonald [Wed, 11 Apr 2012 15:03:19 +0000 (01:03 +1000)]
Make QBoxLayout::insertItem() public.

This commit addresses a Qt 5 to-do comment in the code.  The method was
already protected (so could already be made public by sub-classing),
and already has documentation in qboxlayout.cpp.

Task-number: QTBUG-25098
Change-Id: I5b51d34be8180becb63b8ad291879620f265bbec
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
12 years agoPrefer QCOMPARE to QVERIFY, as it gives better output
João Abecasis [Fri, 6 Apr 2012 07:35:24 +0000 (09:35 +0200)]
Prefer QCOMPARE to QVERIFY, as it gives better output

Done-by: Jędrzej Nowacki
Change-Id: Ic1c8fd5b8acede52b45e5ea16b14fb5bae78f171
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
12 years agoReadd a bunch of tests that had got removed in the QUrl porting
Thiago Macieira [Mon, 2 Apr 2012 22:55:57 +0000 (19:55 -0300)]
Readd a bunch of tests that had got removed in the QUrl porting

Most of the tests were removed while QUrl::toEncoded or fromEncoded
were deprecated in the development process. Since they aren't
deprecated in the end, bring them back.

Change-Id: Ibdb6cd3c4b83869150724a8e327a03a2cd22580d
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
12 years agoChange the component formatting enum values so the default is zero
Thiago Macieira [Fri, 30 Mar 2012 20:48:42 +0000 (17:48 -0300)]
Change the component formatting enum values so the default is zero

By having the default value equal to zero, we follow the principle of
least surprise. For example, if we had
      url.path()
and we refactored to
      url.path(QUrl::DecodeSpaces)

Then instead of ensuring spaces are decoded, we make spaces the only
thing encoded (unicode, delimiters and reserved characters are
encoded).

Besides, modifying the default can only be used to encode something
that wasn't encoded previously, so having the enums as Encode makes
more sense.

As a side-effect, toEncoded() does not support any extra encoding
options.

Change-Id: I2624ec446e65c2d979e9ca2f81bd3db22b00bb13
Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
12 years agoAllow {} to remain decoded in URLs in the path and query
Thiago Macieira [Fri, 30 Mar 2012 19:21:45 +0000 (16:21 -0300)]
Allow {} to remain decoded in URLs in the path and query

This allows things like http://example.com/{1234-5678}?id={abcd-ef01}.
But do not allow it in other parts of the URL. I could allow it in the
fragment, but in the username and password it would be too ugly.

In order to do that, make DecodeReserved use two bits and have
PrettyDecoded set only one of them. That way, toString(PrettyDecoded)
can be distinguished from toString(PrettyDecoded | DecodeReserved),
just as path(PrettyDecoded) can be distinguished from
path(PrettyDecoded & ~DecodeDelimiters).

Also, take the opportunity to avoid decoding the reserved characters
in the query. Keep them encoded as they should be.

Change-Id: I1604a0c8015c6b03dc2fbf49ea9d1dbed96fc186
Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
12 years agoIntroduce QUrl::DecodeReserved and reorder the enums
Thiago Macieira [Fri, 30 Mar 2012 16:32:19 +0000 (13:32 -0300)]
Introduce QUrl::DecodeReserved and reorder the enums

DecodeReserved applies to all characters between 0x21 and 0x7E that
aren't unreserved, a delimiter, or the percent sign itself.

Change-Id: Ie64bddb6b814dfa3bb8380e3aa24de1bb3645a65
Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
12 years agoMerge QUrl::DecodeAllDelimiters and QUrl::DecodeUnambiguousDelimiters
Thiago Macieira [Fri, 30 Mar 2012 13:31:37 +0000 (10:31 -0300)]
Merge QUrl::DecodeAllDelimiters and QUrl::DecodeUnambiguousDelimiters

There's little value in having the DecodeUnambiguousDelimiters option
since neither QUrl nor QUrlQuery can return values that are ambiguous
in that particular context, ever.

This option could be used to encode a character if, when placed
in a URL, it would need to be encoded. Such cases are hash (#) or
question marks (?) in the path component, or slashes (/) and at signs
(@) in the userinfo.

However, we don't need two enums for that, since there are no
other characters that can appear in either form. Still, leave two bits
for this enum. In the future, if we want to split the gen-delims from
the sub-delims, we are able to.

Change-Id: If5416b524680eb67dd4abbe7d072ca0ef7218506
Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
12 years agoAdd a big test for QUrl encoding principles
Thiago Macieira [Tue, 3 Apr 2012 15:42:03 +0000 (12:42 -0300)]
Add a big test for QUrl encoding principles

This tests how QUrl encodes and decodes certain characters and leaves
some other ones alone. It also tests that the output of toString() (in
whichever encoding was being tested) is also parsed again to be
exactly the same as the previously decoded form.

Change-Id: Ie358d001f8b903409db61db48bde1ea679241a60
Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
12 years agoFix the handling of ambiguous delimiters in the query part of a URL
Thiago Macieira [Fri, 30 Mar 2012 01:59:56 +0000 (22:59 -0300)]
Fix the handling of ambiguous delimiters in the query part of a URL

This is the same fix as the previous commit did for the other
components of the URL. But we're also changing how we handle the "[]"
characters in a query: previously the handling was like for other
sub-delims; now, they're always decoded, assuming that the RFC had a
mistake and they were meant to be decoded.

Change-Id: If4b1c3df8f341cb114f2cc4860de22f8bf0be743
Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
12 years agoMake QUrl handle ambiguous delimiters correctly
Thiago Macieira [Fri, 30 Mar 2012 01:11:33 +0000 (22:11 -0300)]
Make QUrl handle ambiguous delimiters correctly

Refactor the way that QUrl stores and returns the components of the
URL so that ambiguous delimiters (gen-delims that could change the
meaning of the parsing) are interpreted correctly. Previously, QUrl
called "unambiguous" the form found in a full URL, even though each
item in isolation could have more characters decoded.

Now, instead, store only the fully decoded form. To recreate the
compound forms (the full URL, as well as the user info and the
authority), we need to do more processing.

This commit applies to the user name, password, path and fragment
only. The scheme, host and port do not need this work because they are
special; the query is handled separately.

Change-Id: I5907ba9b8fe048fff23c128be95668c22820663a
Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
12 years agoFix error reporting in QNetworkReplyHttpImplPrivate
Shane Kearns [Tue, 10 Apr 2012 16:54:22 +0000 (17:54 +0100)]
Fix error reporting in QNetworkReplyHttpImplPrivate

When errors are detected synchronously in _q_startOperation,
they were not reported. This is because unlike the generic
QNetworkReplyImpl the function is called directly rather than
using a queued connection.
In order to report errors, use the _q_error and _q_finished slots
so that signals are emitted after returning to the event loop
i.e. after the application had a chance to connect the QNetworkReply

Change-Id: I8a7bbe79a934f4634fb4e0572ebb5479dfc5f489
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Martin Petersson <Martin.Petersson@nokia.com>
12 years agoAdd unit test for usagePolicies
Shane Kearns [Tue, 10 Apr 2012 12:15:29 +0000 (13:15 +0100)]
Add unit test for usagePolicies

Change-Id: I749268d81521d84ffc709014963a0f34fbf6d74c
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
12 years agoAdd autotest interface to get session from QNAM
Shane Kearns [Tue, 10 Apr 2012 12:10:40 +0000 (13:10 +0100)]
Add autotest interface to get session from QNAM

Change-Id: I7d8ea41299408377042a9f0d0a672e1a6fb57e7d
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Martin Petersson <Martin.Petersson@nokia.com>
12 years agoCheck background requests are allowed before starting
Shane Kearns [Wed, 4 Apr 2012 17:37:54 +0000 (18:37 +0100)]
Check background requests are allowed before starting

If background requests are not allowed, don't even attempt to start
the network session, just fail the request immediately.

After this change, a QNAM with mixed requests queued should behave
as follows when background requests are disabled:
 - background requests at head of the queue fail
 - first foreground request starts the session and succeeds
 - remaining background requests fail
 - remaining foreground requests succeed

If policy is changed on the fly, then running background requests
are not aborted. However queued background requests won't be started.

Change-Id: Ic9aba1eb59ca41b166a08d2ed09418e1b6af6b60
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Martin Petersson <Martin.Petersson@nokia.com>
12 years agoDefine usagePolicies API in QNetworkSession
Shane Kearns [Wed, 4 Apr 2012 17:11:42 +0000 (18:11 +0100)]
Define usagePolicies API in QNetworkSession

This allows the system to publish usage restrictions to applications
related to the network in use.
Currently there is only one restriction defined:
NoBackgroundTrafficPolicy, which means that non user initiated traffic
should be avoided (e.g. background downloads).
For example this policy could be applied to save battery or data transfer
charges.

Change-Id: I49e26c0f3650d2b92f4ec51981aae9435b717b49
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
12 years agoUse NetworkSessionFailedError in QNetworkReply
Shane Kearns [Wed, 4 Apr 2012 15:31:09 +0000 (16:31 +0100)]
Use NetworkSessionFailedError in QNetworkReply

Switched the error code.
Republish the error string from the bearer plugin if possible.

Change-Id: I9e4ac7a9914fbf2e87fe8fd3a5175deda6d933d2
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Martin Petersson <Martin.Petersson@nokia.com>
12 years agoDefine QNetworkReply::BackgroundRequestNotAllowedError
Shane Kearns [Wed, 4 Apr 2012 15:14:57 +0000 (16:14 +0100)]
Define QNetworkReply::BackgroundRequestNotAllowedError

This error will be used when background network requests are not allowed
according to the current policy of the bearer plugin.
For example, to save power when battery is low on a portable device.

Change-Id: I866e115f8fdd046134da99ea895b7c1df0375f26
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Martin Petersson <Martin.Petersson@nokia.com>
12 years agoDefine QNetworkReply::NetworkSessionFailed error
Shane Kearns [Wed, 4 Apr 2012 15:11:53 +0000 (16:11 +0100)]
Define QNetworkReply::NetworkSessionFailed error

This is to replace the UnknownNetworkError which occurs when the
internal QNetworkSession fails to start (e.g. no usable WLAN available)

Change-Id: I2b14577c22e0acf8ff07be7e932f0dfe9ac89c33
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Martin Petersson <Martin.Petersson@nokia.com>
12 years agoSet ConnectInBackground based on request
Shane Kearns [Wed, 4 Apr 2012 14:45:22 +0000 (15:45 +0100)]
Set ConnectInBackground based on request

Set the QNetworkSession attribute to match the QNetworkRequest that
triggered it.
Currently if there are a mix of normal and background requests queued
and background connections are not allowed by policy:
 - background requests at the head of the queue should fail
 - first foreground request should successfully start a connection
 - remaining requests succeed regardless of background attribute

Change-Id: If0e3ec0b8a5096e3d7cd6df85884c6f53172d233
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Martin Petersson <Martin.Petersson@nokia.com>
12 years agoDefine BackgroundRequestAttribute
Shane Kearns [Wed, 4 Apr 2012 14:20:05 +0000 (15:20 +0100)]
Define BackgroundRequestAttribute

This is so that the ConnectInBackground flag can be set on the
QNetworkSession internal to QNAM according to pending requests.

Change-Id: If0cc62f5117ed8febbbda7b7f6de62b11b274258
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Martin Petersson <Martin.Petersson@nokia.com>
12 years agoMove QVectorPath::polygonFlags to its own class.
Robin Burchell [Wed, 11 Apr 2012 08:09:26 +0000 (10:09 +0200)]
Move QVectorPath::polygonFlags to its own class.

Who can say why it was put in QPaintEngineEx's header, but it certainly doesn't
belong there.

Change-Id: Ieb3b977affcf4b240f621d13b72bdc0e8f8138b9
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
12 years agoMove QRectVectorPath into the .cpp of the only file actually using it.
Robin Burchell [Wed, 11 Apr 2012 08:26:50 +0000 (10:26 +0200)]
Move QRectVectorPath into the .cpp of the only file actually using it.

Change-Id: I2778b5142ee574f44a9f9489a2752265c6a6c170
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
12 years agounite QString::normalized() overloads
Konstantin Ritt [Wed, 4 Apr 2012 23:29:35 +0000 (02:29 +0300)]
unite QString::normalized() overloads

Change-Id: I27545e599a1831728e491a9fad1e52fa255535fc
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
12 years agoDeprecate qMemCopy/qMemSet in favour of their stdlib equivilents.
Robin Burchell [Fri, 6 Apr 2012 14:34:19 +0000 (16:34 +0200)]
Deprecate qMemCopy/qMemSet in favour of their stdlib equivilents.

Just like qMalloc/qRealloc/qFree, there is absolutely no reason to wrap these
functions just to avoid an include, except to pay for it with worse runtime
performance.

On OS X, on byte sizes from 50 up to 1000, calling memset directly is 28-15%
faster(!) than adding an additional call to qMemSet. The advantage on sizes
above that is unmeasurable.

For qMemCopy, the benefits are a little more modest: 16-7%.

Change-Id: I98aa92bb765aea0448e3f20af42a039b369af0b3
Reviewed-by: Giuseppe D'Angelo <dangelog@gmail.com>
Reviewed-by: John Brooks <john.brooks@dereferenced.net>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
12 years agoMark QObject::disconnect overload const
Olivier Goffart [Mon, 9 Apr 2012 11:38:03 +0000 (13:38 +0200)]
Mark QObject::disconnect overload const

Consistency with the non-static connect overload

Task-number: QTBUG-23622
Task-number: QTBUG-1772
Change-Id: Ic09df9cca1feaabb6b5cf335f04a0d6d4bbf011f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
12 years agoMake reallocData() take (unsigned) size, including null
João Abecasis [Wed, 4 Apr 2012 13:00:41 +0000 (15:00 +0200)]
Make reallocData() take (unsigned) size, including null

The parameter represents an allocation size and unsigned matches the
Q*Data::alloc member it ultimately represents (even if they currently
differ in accounting for the null).

There's still work up for grabs to ensure we avoid integer overflows
when growing.

Change-Id: Ib092fec37ec2ceed37bebfdc52e2de27b336328f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
12 years agoAdjust a double leading slash in the path for FTP to /%2F
Thiago Macieira [Tue, 3 Apr 2012 16:58:39 +0000 (13:58 -0300)]
Adjust a double leading slash in the path for FTP to /%2F

Some FTP implementations (currently not including QNAM) strip the first
slash off the path in an FTP URL so that the path in the URL is relative
to the login path (the user's home directory). To reach the root
directory, another slash is necessary, hence the double slash.

In anticipation of future URL normalisation, which Qt 4 could do, "//"
could be rendered to "/", so this extra slash should be "%2F".

This operation is done only in QUrl::fromUserInput.

Change-Id: If9619ef6b546a3f4026cb26b74a7a5a865123609
Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
12 years agoAdd early-clobbers to the output variables in CPUID
Thiago Macieira [Tue, 10 Apr 2012 15:08:21 +0000 (12:08 -0300)]
Add early-clobbers to the output variables in CPUID

Without those early-clobbers, the compiler might decide to schedule a
register that is also used as output. The existing early clobber in
the tmp variable was there so the compiler wouldn't use a register
scheduled as input (especially EAX).

To be honest, I'm not convinced that the compiler should be allowed to
do this. That means that two output variables are scheduled to the
same register... still, this fixes a problem found with GCC 4.2 (at
least the Mac one).

Change-Id: I6cd4676284e9a83d6aac4b439c6e58e347c40106
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
12 years agoMake plugin linking fail if some references aren't present
Thiago Macieira [Fri, 23 Dec 2011 12:47:15 +0000 (10:47 -0200)]
Make plugin linking fail if some references aren't present

It's better to fail at linking time than to try and figure out later why
QPluginLoader refuses to load the plugin.

Change-Id: I439bad9dcdbfff9f76efe40381fd7ccfffe738bc
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Reviewed-by: Donald Carr <donald.carr@nokia.com>
Reviewed-by: Girish Ramakrishnan <girish.1.ramakrishnan@nokia.com>
12 years agoMerge remote-tracking branch 'origin/master' into api_changes
Oswald Buddenhagen [Tue, 10 Apr 2012 10:48:01 +0000 (12:48 +0200)]
Merge remote-tracking branch 'origin/master' into api_changes

Conflicts:
configure
src/widgets/styles/qwindowsxpstyle.cpp
tests/auto/gui/kernel/qwindow/qwindow.pro
tests/auto/gui/kernel/qwindow/tst_qwindow.cpp

Change-Id: I624b6d26abce9874c610c04954c1c45bc074bef3

12 years agoRemoved QApplication overloads used solely for documentation.
Marcel Krems [Thu, 5 Apr 2012 20:12:15 +0000 (22:12 +0200)]
Removed QApplication overloads used solely for documentation.

Also removed a define which was used only for this purpose.

This change brings the constructors in line with Q{Core,Gui}Application.

Change-Id: I1134ca5611453e8445c1a4f3226846621fa8872c
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
12 years agoNew qHash algorithm for uchar/ushort arrays (QString, QByteArray, etc.)
Giuseppe D'Angelo [Tue, 27 Mar 2012 17:40:06 +0000 (18:40 +0100)]
New qHash algorithm for uchar/ushort arrays (QString, QByteArray, etc.)

Port of Robin's work from I0a53aa4581e25b351b9cb5033415b5163d05fe71
on top of the new qHash patches (the original commit just introduced
lots of conflicts, so I redid it from scratch).

This is based on the work done in the QHash benchmark over the past
few months experimenting with the performance of the string hashing
algorithm used by Java.

The Java algorithm, in turn, appears to have been based off a
variant of djb's work at http://cr.yp.to/cdb/cdb.txt.

This commit provides a performance boost of ~12-33% on the
QHash benchmark.

Unfortunately, the rcc test depends on QHash ordering.
Randomizing QHash or changing qHash will cause the test to fail
(see QTBUG-25078), so for now the testdata is changed as well.

Done-with: Robin Burchell
Change-Id: Ie05d8e21588d1b2d4bd555ef254e1eb101864b75
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
12 years agoStop relying on qHash always giving the same results
Giuseppe D'Angelo [Thu, 22 Mar 2012 09:32:03 +0000 (09:32 +0000)]
Stop relying on qHash always giving the same results

The implementation of the various qHash overloads offered by
Qt can change at any time for any reason
(speed, quality, security, ...).

Therefore, relying on the fact that qHash will always give
an identical result across Qt versions (... across different
processes, etc.), given identical input, is wrong.
Note that this also implies that one cannot rely on QHash
having a stable ordering (even without the random qHash seed).

For such use cases, one must use f.i. a private hash function
that will never change outside his own control.

This patch adds a private hash function for QStrings,
which is identical to the Qt(4) qHash(QString) implementation.
A couple of spots in Qt where the results of a qHash call were
actually saved on disk are ported to use the new function,
and a bit of documentation is added to QHash docs.

Change-Id: Ia3731ea26ac68649b535b95e9f36fbec3df693c8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
12 years agoQHostAddress: improve qHash implementation
Giuseppe D'Angelo [Wed, 4 Apr 2012 19:37:04 +0000 (20:37 +0100)]
QHostAddress: improve qHash implementation

Avoid the conversion to a temporary QString -- just hash the address
as a byte array.

Change-Id: Ic35cdbbc3ee66c32a28d911bd27de0092395979f
Done-with: Shane Kearns
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
12 years agoQUrl: added two-arguments qHash support
Giuseppe D'Angelo [Wed, 4 Apr 2012 19:19:39 +0000 (20:19 +0100)]
QUrl: added two-arguments qHash support

An unnecessary #include <QHash> was also removed, and other
includes refactored.

Change-Id: Ifcd3e37d75029c142a2e55ab492b88624505670a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
12 years agoMore qHash(T, uint) overloads for Qt types
Giuseppe D'Angelo [Sat, 24 Mar 2012 18:23:49 +0000 (18:23 +0000)]
More qHash(T, uint) overloads for Qt types

The more we get in 5.0, the better.

Change-Id: If00084477709db4fc3f6b2e15024d046491be2ae
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
12 years agoQFileSystemModel: fix sorting
Giuseppe D'Angelo [Sun, 1 Apr 2012 17:47:56 +0000 (18:47 +0100)]
QFileSystemModel: fix sorting

When sorting a model recursively, the children of a QFileSystemNode
are extracted from their parent in a QHash order; then filtered,
then sorted (using a stable sort) depending on the sorting column.

This means that the order of the children comparing to equal for
the chosen sort are shown in the order they were picked from the
iteration on the QHash, which isn't reliable at all.

Moreover, the criteria used in QFileSystemModelSorter for sorting
are too loose: when sorting by any column but the name, if the result
is "equality", then the file names should be used to determine
the sort order.

This patch removes the stable sort in favour of a full sort,
and fixes the criteria of soring inside QFileSystemModelSorter.

Change-Id: Idd9aece22f2ebbe77ec40d372b43cde4c200ff38
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
12 years agoRemove -DQT_NO_STL from the bootstrapped builds
Thiago Macieira [Mon, 26 Mar 2012 18:34:23 +0000 (15:34 -0300)]
Remove -DQT_NO_STL from the bootstrapped builds

Change-Id: I37ea06426b66e617a49ec46952abdaad8814eadf
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
12 years agoRemove references to QT_NO_STL from QtConcurrent
Thiago Macieira [Mon, 26 Mar 2012 18:29:34 +0000 (15:29 -0300)]
Remove references to QT_NO_STL from QtConcurrent

Same as with QtCore, remove the #ifdef and #ifndef and select the side
with STL.

Change-Id: If1440080328c7c51afe35f5944a19dafc4761ee5
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
12 years agoRemove references to QT_NO_STL from QtCore
Thiago Macieira [Mon, 26 Mar 2012 18:28:40 +0000 (15:28 -0300)]
Remove references to QT_NO_STL from QtCore

QT_NO_STL is now no longer defined, so remove the conditionals and
select the STL side.

Change-Id: Ieedd248ae16e5a128b4ac287f850b3ebc8fb6181
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
12 years agoqHash: always use the seed in the catch-all template
Giuseppe D'Angelo [Wed, 4 Apr 2012 15:21:03 +0000 (16:21 +0100)]
qHash: always use the seed in the catch-all template

This pertubates the results of the calls to the one-argument
version of qHash through the catch-all template.

Change-Id: I7037b25d545e6f1360384a83ff895f4bb62ed195
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
12 years agoAdd test for qHash(QByteArray)
Giuseppe D'Angelo [Wed, 4 Apr 2012 20:00:11 +0000 (21:00 +0100)]
Add test for qHash(QByteArray)

Two equal QByteArrays must return the same hash.

Change-Id: Iddd45b0c420213ca2b82bbcb164367acb6104ec8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
12 years agoAdd test for qHash(QString) / qHash(QStringRef)
Giuseppe D'Angelo [Wed, 4 Apr 2012 19:44:33 +0000 (20:44 +0100)]
Add test for qHash(QString) / qHash(QStringRef)

Two equal strings / stringrefs must return the same hash.

Change-Id: I2af9a11ab721ca25f4039048a7e5f260e6ff0148
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
12 years agoFix compilation with MinGW.
Marcel Krems [Thu, 5 Apr 2012 21:15:51 +0000 (23:15 +0200)]
Fix compilation with MinGW.

Change-Id: I494c84e8e6889a7d7bb3b29669337483732d02c2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
12 years agoQLatin1String: add qHash overload
Giuseppe D'Angelo [Sun, 25 Mar 2012 07:18:15 +0000 (08:18 +0100)]
QLatin1String: add qHash overload

It was never introduced in Qt 4, probably because of the implicit
conversion to QString (that is, adding the qHash overload for
QLatin1String in Qt 4 would have been a BIC).

Change-Id: I2ebc8e73a85be497866820e0ca416dd11167bb53
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
12 years agoFind libssl on linux using paths of loaded libraries
Shane Kearns [Wed, 28 Mar 2012 15:06:57 +0000 (16:06 +0100)]
Find libssl on linux using paths of loaded libraries

The installed path of libssl may include an element describing the
architecture, e.g. x86_64-linux-gnu or i386-linux-gnu.
In most cases, the libraries already loaded (static dependencies of
Qt, such as libc) will include the path where libssl is installed.

Use dl_iterate_phdr to find the paths. This is a linux specific
function, but it does provide "/lib/<arch>" and "/usr/lib/<arch>"
at the point ssl symbols are being resolved when running the
qsslsocket autotest (which has less dependencies than a typical
Qt app).

Task-number: QTBUG-24694
Change-Id: I9af8081f41bb85c2fcff450a2acda5672a7f7518
Reviewed-by: Harald Fernengel <harald.fernengel@nokia.com>
12 years agoEnable variadic macros for MSVC >= 2005
João Abecasis [Thu, 5 Apr 2012 08:24:41 +0000 (10:24 +0200)]
Enable variadic macros for MSVC >= 2005

Change-Id: I8793ea0f6e3a640276b073321d29373b2ed18d63
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
12 years agoWindows: Use native font engine by default.
Friedemann Kleint [Tue, 27 Mar 2012 15:05:53 +0000 (17:05 +0200)]
Windows: Use native font engine by default.

Turn around the meaning of the command line parameter.
The FreeType engine can now be activated by passing freetype.

Change-Id: I9da6cd4a127603f9cfb91f0ce8450088c0883faa
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
12 years agoInclude with qt module to avoid configure warning
Pekka Vuorela [Tue, 3 Apr 2012 15:49:23 +0000 (18:49 +0300)]
Include with qt module to avoid configure warning

Change-Id: I8d338f22c4b0dabcca33878b33c6a203828d84c5
Reviewed-by: David Faure <faure@kde.org>
12 years agoFix unittest for QStandardPaths::enableTestMode
David Faure [Wed, 4 Apr 2012 19:43:53 +0000 (21:43 +0200)]
Fix unittest for QStandardPaths::enableTestMode

It was confusing DataLocation and GenericDataLocation, and the same
for CacheLocation and GenericCacheLocation. The test was passing in
the api_changes branch because these were giving the same result
(empty app name), but the QCoreApplication::applicationName fix in master
makes these different, so the bug in the test showed up after merging.

Change-Id: I80ef6883c96cfd02b8c277d9d686717028d396bb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
12 years agoAdd zero-termination checks to QString and QByteArray tests
João Abecasis [Tue, 3 Apr 2012 23:26:44 +0000 (01:26 +0200)]
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>
12 years agoRevert "Add tests to verify QByteArray's zero termination"
João Abecasis [Tue, 3 Apr 2012 23:29:26 +0000 (01:29 +0200)]
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 4ef5a6269c1465662ea3872596ba284a13cce25e.

Change-Id: I862434a072f447f7f0c4bbf8f757ba216212db3c
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
12 years agoFixed an exit crash that could occur in QQuickPixmap.
Charles Yin [Wed, 4 Apr 2012 01:59:39 +0000 (11:59 +1000)]
Fixed an exit crash that could occur in QQuickPixmap.

The global destructor for the clean up hooks might be called before the
global destructor for QQuickPixmapCache objects.

This is an additional fix for QTBUG-8681

Task-number: QTBUG-8681
Change-Id: I8694a7a246980f488aef78071c613e3a908c7db3
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
12 years agoMake QLocale::toULongLong return the proper type: qulonglong
Thiago Macieira [Wed, 4 Apr 2012 16:51:33 +0000 (13:51 -0300)]
Make QLocale::toULongLong return the proper type: qulonglong

Task-number: QTBUG-25143
Change-Id: Ia8fd588c25d11fe31acd57fd34a90d51dace248c
Reviewed-by: Giuseppe D'Angelo <dangelog@gmail.com>
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
Reviewed-by: John Layt <jlayt@kde.org>
12 years agoGet rid of QKeyEventEx
Thiago Macieira [Wed, 4 Apr 2012 18:36:21 +0000 (15:36 -0300)]
Get rid of QKeyEventEx

This class was added when we needed more information in QKeyEvent but
couldn't extend it. And we couldn't use the d pointer because the copy
constructor and copy assignment operators in QEvent were
implicit. That is now fixed.

But since this is Qt 5, we can change QKeyEvent to include the extra
information.

Task-number: QTBUG-25070
Change-Id: Iba4ac3378ca70583fcaa8caf96bca8ef75e30701
Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com>
12 years agoRemove macro _POSIX_ from Win32 special file
Debao Zhang [Thu, 5 Apr 2012 00:23:46 +0000 (17:23 -0700)]
Remove macro _POSIX_ from Win32 special file

Macro _POSIX_ doesn't used by this two files. And it will casued compile
errors under VS2005/VS2008/VS2010 such as:

Error 19 error C3861: \91_fileno\92: identifier not found c:\Dev\Builds\Qt\qt-everywhere-opensource-src-4.8.1\src\corelib\io\qfsfileengine_win.cpp 443
Error 20 error C3861: \91_fileno\92: identifier not found c:\Dev\Builds\Qt\qt-everywhere-opensource-src-4.8.1\src\corelib\io\qfsfileengine_win.cpp 468
Error 21 error C3861: \91_fileno\92: identifier not found c:\Dev\Builds\Qt\qt-everywhere-opensource-src-4.8.1\src\corelib\io\qfsfileengine_win.cpp 607

when we don't use precompiled headers. And this error will triggered when
we reomve QT_NO_STL from QtCore.

Because stdio.h declares fileno instead of _fileno when _POSIX_ is
defined.

Change-Id: I9d9031578dac7b7c5f7b77098839723a4bc8bfdf
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
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 agoSpecify generic QPA plugins via env variables
Donald Carr [Mon, 2 Apr 2012 18:10:49 +0000 (18:10 +0000)]
Specify generic QPA plugins via env variables

Introduce a mechanism to load comma separated generic QPA plugins via
exported environment variables. (Drastically simplifies QPA usage in custom
environments where a variety of plugins could be used and heuristics are
consequently a poor fit)

Change-Id: I292f3fbfc8b8ad2b4f416984ef0a10b9b59de531
Reviewed-by: Girish Ramakrishnan <girish.1.ramakrishnan@nokia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
12 years agoDon't ignore tst_QWindow on Mac OS X
Bradley T. Hughes [Wed, 4 Apr 2012 10:16:40 +0000 (12:16 +0200)]
Don't ignore tst_QWindow on Mac OS X

QTBUG-23059 only affects 2 test functions, not the whole test. XFAIL the
2 failing tests.

Change-Id: I87086a9ec573362625bc090038dfd7c79aeb9426
Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>
12 years agodevice: Add device support for the Broadcom Raspberry PI
Donald Carr [Wed, 28 Mar 2012 19:23:50 +0000 (19:23 +0000)]
device: Add device support for the Broadcom Raspberry PI

Add mkspec for the Raspberry PI platform to be used in conjunction with the
-device support in configure. This allows you to build Qt with the
application libraries provided by the Raspberry PI foundation.

The Raspberry PI is described here:

http://en.wikipedia.org/wiki/Raspberry_Pi

and its use with Qt is documented here:

http://wiki.qt-project.org/Devices/RaspberryPi

Change-Id: Ib8d11d0a469edaaf34ccc04cf33a42a725fc2bdb
Reviewed-by: Girish Ramakrishnan <girish.1.ramakrishnan@nokia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
12 years agoChange the parameter name of the mutex in a QWaitCondition.
Stephen Kelly [Wed, 4 Apr 2012 12:33:25 +0000 (14:33 +0200)]
Change the parameter name of the mutex in a QWaitCondition.

IDEs pick up hints like this, so it makes it more clear to the user
what they need to pass in.

Change-Id: I5de272395fc98391cf43963ce4416a845726bb2c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
12 years agoRevert "Make the CONFIG and QT_CONFIG contents available downstream."
Stephen Kelly [Tue, 3 Apr 2012 17:32:12 +0000 (19:32 +0200)]
Revert "Make the CONFIG and QT_CONFIG contents available downstream."

This reverts commit 6c2e57e6884c1ef524bb22f0ed6a2be2c97cd46d.

This created variables with awkward names and unproven usefulness.
In the FindQt4.cmake file they are considered internal.

Change-Id: I51443b2a39d4f11817bd13332baf025556dd8ebe
Reviewed-by: Clinton Stimpson <clinton@elemtech.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
12 years agoWindows Vista: Fix painting of item view items.
Friedemann Kleint [Wed, 4 Apr 2012 12:56:45 +0000 (14:56 +0200)]
Windows Vista: Fix painting of item view items.

The old QWidget-based treeViewHelper() function silently failed
since the widget no longer had a HWND.
Use a native Window handle instead.

Change-Id: I6902677c565bb165f29b9d1c6fd0d28d9870d567
Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com>
12 years agoWindows: Replace QString keys of XP themes by an enumeration.
Friedemann Kleint [Wed, 4 Apr 2012 12:02:27 +0000 (14:02 +0200)]
Windows: Replace QString keys of XP themes by an enumeration.

Change-Id: I5323e9ed5bc3fe73f278d167acae6fa744b0a299
Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com>
12 years agoUpdate the documentation about the sign in QElapsedTimer::(m)secsTo
Thiago Macieira [Mon, 2 Apr 2012 18:25:29 +0000 (15:25 -0300)]
Update the documentation about the sign in QElapsedTimer::(m)secsTo

Since all implementations calculate other - *this, if other has a higher
value (was started later), then the returned value is positive.

The implementations are:
generic: return other.t1 - t1
win: return ticksToNanoseconds(other.t1 - t1) / 1000000
mac: return absoluteToMSecs(other.t1 - t1);
unix: return (other.t1 - t1) * Q_INT64_C(1000) + fraction...

Task-number: QTBUG-25128
Change-Id: Iff0a3460ae9e9d9bdd82fbaad55657fb60e5235a
Reviewed-by: Giuseppe D'Angelo <dangelog@gmail.com>
Reviewed-by: Casper van Donderen <casper.vandonderen@nokia.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 agoMake sure we create an application before a QWidget.
Stephen Kelly [Wed, 4 Apr 2012 12:29:48 +0000 (14:29 +0200)]
Make sure we create an application before a QWidget.

Change-Id: I2e48f9ca59df62ac28d3cecdb6c2b741c59075de
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
12 years agoeglfs: Introduce hooks for the eglfs plugin
Girish Ramakrishnan [Fri, 16 Mar 2012 23:52:39 +0000 (16:52 -0700)]
eglfs: Introduce hooks for the eglfs plugin

EGL provides an api to create a rendering context for khronos APIs
on native surfaces. The board initialization and window creation
is platform specific.

This commit adds platform hooks/extensions to the EGLFS plugin and
implements them for the Amlogic 8726M. The hook interface is internal
and there are no ABI/API guarantees.

EGLFS is now linked with -Wl,-no-undefined to make sure that a hook does not
add unresolvable symbols.

Change-Id: I7f4fcdb422aacbf00de468f4d8e85ae5368bfacf
Reviewed-by: Girish Ramakrishnan <girish.1.ramakrishnan@nokia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.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 agoWindows: Fix menu color for Windows, WindowsXP.
Friedemann Kleint [Wed, 4 Apr 2012 09:55:24 +0000 (11:55 +0200)]
Windows: Fix menu color for Windows, WindowsXP.

Typo in palette.

Change-Id: I8b4c23ef7f75ff3aa3351f15e4af0767a3ccd083
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
12 years agoAdd tst_QWindow::windowModality()
Bradley T. Hughes [Wed, 4 Apr 2012 10:11:40 +0000 (12:11 +0200)]
Add tst_QWindow::windowModality()

This tests that we get the windowModalityChanged() signal as needed, but
not unnecessarily either.

Change-Id: I2232fa9d45c72e472b324b681859b4b0d574b467
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
12 years agoRemove/update Qt 5 to-do's that won't be done for Qt 5.
Jason McDonald [Mon, 2 Apr 2012 13:03:57 +0000 (23:03 +1000)]
Remove/update Qt 5 to-do's that won't be done for Qt 5.

Task-number: QTBUG-23524
Change-Id: Iebf5b78dc2ff27310b5a484bae588862417f693c
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.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>