Commit Graph

1278 Commits

Author SHA1 Message Date
Mitch Curtis
8a680201f1 Fix roundtrip conversion of datetimes.
QDateTime.toString() is writing out milliseconds since change
15da0a5af2. Unfortunately this breaks
QDateTime::fromString() with Qt::TextDate which can't handle the new
format.

Fix by making QDateTime::fromString split up seconds and milliseconds
on a period, if any. Now
QDateTime dt = ...;
assert(QDateTime::fromString(dt.toString(), Qt::TextDate) == dt)
works again.

Change-Id: Ibfe9032e357ceaf894e33f3e33affe94f56dbf5c
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-06-17 13:21:49 +02:00
Frederik Gladhorn
e2776b44a0 Merge remote-tracking branch 'origin/stable' into dev
Conflicts:
	src/plugins/platforms/cocoa/qcocoamenubar.mm

Change-Id: I4a699fc8a7f30b2af9de8e496c3d5f027b7495bb
2013-06-12 19:17:07 +02:00
Frederik Gladhorn
75067b56fa Merge "Merge remote-tracking branch 'origin/release' into stable" into refs/staging/stable 2013-06-10 19:54:53 +02:00
Rafael Roquetto
e554ab4585 BlackBerry: fix tst_QLocale::emptyCtor()
BlackBerry OS does not allow for explicitly controlling the locale through the
"LANG" environment variable. Locale is controlled by the underlying PPS
Service instead.

Change-Id: I22154e39f81a9467ad7fdb90a042396390398b1b
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Kevin Krammer <kevin.krammer@kdab.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Mehdi Fekari <mfekari@blackberry.com>
2013-06-10 16:32:57 +02:00
Frederik Gladhorn
0eff16611f Merge remote-tracking branch 'origin/release' into stable
Change-Id: I89c251999ae2a82522b40471fd13f2e06b00ece8
2013-06-10 10:00:34 +02:00
Thiago Macieira
ebea15cb33 QEventLoop: Remove the test that checked throwing from an event handler
In Qt 5, we declared that throwing from event handlers is undefined
behavior. So stop testing this.

We will try our best to capture and pass along std::bad_alloc, but even
that might not work, depending on compiler settings. In particular,
after the upgrade to MinGW/GCC 4.8 with DW2, this test stopped working.

Task-number: QTBUG-31615
Change-Id: Ibf5fb2ce0c48b983549096bf7aac434b6ed3ac2e
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-06-08 23:00:50 +02:00
Thiago Macieira
9095210c0b tst_QUrl: check that prohibited characters in hostnames are not valid
qt_nameprep is tested by tst_qurlinternal. We just need to be sure that
QUrl handles them correctly.

Change-Id: Ic563004870d2cf2fa7a31ce49fff7280d5ffb5f3
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
2013-06-08 15:20:44 +02:00
Friedemann Kleint
a730b5fabf tst_qmessageauthenticationcode: Fix warning about character conversion.
warning C4309: 'argument' : truncation of constant value.

Change-Id: I54e9b515d065c1a89bf790fb214c335e852ce5ac
Reviewed-by: Mitch Curtis <mitch.curtis@digia.com>
2013-06-08 10:29:34 +02:00
Friedemann Kleint
876202ddf2 tst_qjson: Fix MSVC C4293 warning about shift operation.
warning C4293: '<<' : shift count negative or too big,
undefined behavior.

Change-Id: I858dd08f16ea0e00f2384491fc735b7367c6925d
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-06-08 10:29:34 +02:00
Thiago Macieira
4d93393a6d QUrl stringprep: fix handling of U+0080: it's prohibited
Edge case: a > that should have been >=. Without it, we never ran the
rest of the IDN nameprepping.

Change-Id: I2276d660de3a70d0c561bb18816820d9a0f47e77
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
2013-06-08 05:06:57 +02:00
Thiago Macieira
736a052d93 QUrl stringprep: fix handling of prohibited characters
RFC 3454 says about prohibited characters (section 2, "Preparation
Overview"):

   3) Prohibit -- Check for any characters that are not allowed in the
      output.  If any are found, return an error.  This is described in
      section 5.

In other words, we mustn't simply strip the output of prohibited
characters. We must generate an error if they are present. We do that by
clearing the data.

We already had tests for prohibited output, but they were
indistinguishable from being stripped. So instead add some extra
characters so that we can tell whether the label was cleared.

Change-Id: I2d95217c27be5e2d54deed0036cb009e3b7f4886
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
2013-06-08 05:06:47 +02:00
Rafael Roquetto
d4dba8a5c4 Unix: fix tst_QFile when run as root
Because tests are usually run as root on some setups, it does not
make sense to test for the right permissions of a readonly file.

Change-Id: I484f88722d3a9ce7123edc0fb57acae528fa194e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2013-06-07 22:18:42 +02:00
Simon Hausmann
d8a6a67579 Add internal functions to QObjectPrivate for signal & slot connections in QML
In QML it is common to connect signals to slots that are implemented as
JavaScript functions. QML used to maintain separate data structures that
mirrored the QObject connection list and kept references to the JavaScript
objects necessary to perform the call on signal activation.

The recent addition of functor based QObject::connect makes it possible
to store this information in QSlotObjectBase sub-class instead, which
eliminates any extra bookkeeping.

This patch adds internal connect and disconnect overloads to QObjectPrivate
that allow for connecting QObject *sender, int signalIndex to a given
QSlotObjectBase and similar for disconnect.

Change-Id: I90f43d13eb95bd884d752484cf4faacc446f4d6a
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
2013-06-07 16:19:05 +02:00
Frederik Gladhorn
80604a0786 Merge remote-tracking branch 'origin/stable' into dev
Conflicts:
	src/corelib/global/qglobal.h
	src/plugins/platforms/cocoa/qnsview.mm

Change-Id: I6fe345df5c417cb7a55a3f91285d9b47a22c04fa
2013-06-04 19:34:36 +02:00
Mitch Curtis
15da0a5af2 Make QTime::toString output milliseconds for Qt::TextDate, Qt::ISODate.
Section 4.2.2.4 of ISO 8601 allows for decimal fraction representations
of dates and times. Currently, when calling
QDateTime::toString(Qt::TextDate) or QDateTime::toString(Qt::ISODate),
the milliseconds will be omitted. However,
QDateTime::fromString(str, Qt::TextDate) and
QDateTime::fromString(str, Qt::ISODate) already support decimal
fraction representations, so this patch just adds this support to
QTime::toString, and hence QDateTime::toString().

Task-number: QTBUG-30250
Change-Id: If58e4b3d3105322c51d11a76b832e5e634d8991f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2013-06-03 17:05:12 +02:00
Christoph Schleifenbaum
7ed15da3c1 Core: QDebug and comparison operator support metatypes.
This patch adds a way to enable operator<, operator== and operator<<
into QDebug for QVariants with custom types.

Change-Id: I3d12d891bd7252ad2b8f1de69bced354800a1f29
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
2013-05-27 19:58:19 +02:00
Lars Knoll
7878eb6ba3 Fix parsing of long latin strings in the json parser
Latin1 strings are usually stored as 8 bit data in the json binary
format. But that data structure has a size limitation of 16bit, so
we need to fall back to storing the string as 16 bit data if it is
too long.

Task-number: QTBUG-30946
Change-Id: I0069b1367030b0b2f819fd1f04e34c9e2534a2a3
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
2013-05-23 22:00:46 +02:00
Frederik Gladhorn
d3a8bc803c Merge remote-tracking branch 'origin/stable' into dev
Conflicts:
	src/corelib/io/qdatastream.cpp
	src/corelib/io/qdatastream.h
	src/corelib/json/qjsonwriter.cpp
	src/plugins/platforms/cocoa/qcocoawindow.mm
	src/plugins/platforms/xcb/qxcbkeyboard.cpp

Change-Id: I46fef1455f5a9f2ce1ec394a3c65881093c51b62
2013-05-23 21:27:07 +02:00
Mitch Curtis
964be00403 Fix regression when pasting into QTextEdit from Firefox.
Return the codec if one was found by QTextCodec::codecForUtfText,
instead of returning the default (UTF-8).

Task-number: QTBUG-31293

Change-Id: I95e3260376c00537006b7fbfdc3df5850e1ba657
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2013-05-23 16:55:30 +02:00
Stephen Kelly
b88b09fb16 Make it possible to access QPair and std::pair elements from a QVariant.
Change-Id: I9dc73748073d0d1e43bdadbce73339dfcc1bc647
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
2013-05-20 13:19:16 +02:00
Thiago Macieira
6c98035c99 QThreadPool: Fix regression from Qt 4 in dealing with priority starts
The optimisation done in cbaf52b099 for Qt
5.0 got the order wrong of the comparison. The queue must be sorted in
decreasing priority order. But since higher numbers mean higher
priority, that means the queue must be sorted in decreasing priority
number order.

Task-number: QTBUG-29163
Change-Id: Iaf3424b9bb445bf5c71518927f37253cead454f3
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
2013-05-20 12:06:48 +02:00
Liang Qi
57acf1b46c QtCore: fix the number precision in QJsonDocument.toJson()
In JSON, any number is stored in double. We need to make sure we
keep the maximum possible number precision for integer number. In
IEEE 754 double format, the significand precision is 53 bits(52
explicityly stored).

Autotest is included. qint64 and double work fine.

Task-number: QTBUG-28467
Change-Id: I7f857671c50e4334e9329c778f9b4f090f490540
Reviewed-by: Sune Vuorela <sune@vuorela.dk>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2013-05-20 12:06:48 +02:00
Stephen Kelly
87e27eb870 Add container access functionality for associative containers in QVariant.
Change-Id: I4763a4c157e52918a0a68cba63624c0649aca235
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
2013-05-20 09:09:06 +02:00
Stephen Kelly
1da8cd6e48 Don't test QHash<float, U> or QHash<double, U>
Although it is possible to construct those containers, they are not
usable, as qHash(float) and qHash(double) are ambiguous.

Also don't use CustomMovable as a container key.

It is not equality or lessthan comparable.

Change-Id: I8c7ee068250e2e2b3427769153e3017721c13c50
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
2013-05-20 09:08:47 +02:00
David Faure
f22b29162c Fix some data races in tst_qthreadpool.
Detected by helgrind.

Change-Id: I5f73a62610b4bdc7f26629f3dcf7b11467897a5c
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
2013-05-19 20:39:32 +02:00
Albert Astals Cid
95cab90b10 Make QFlags enum flags (C++11 strict enums) friendly
Change-Id: I9ccb3e4d281a545ca1845db4f6aa7ac6c04e8621
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
2013-05-09 12:17:59 +02:00
Olivier Goffart
9cc106d9d7 Fix a case of connect()ing to signals declared in a base class
Fix connection to pointer to member signal that belongs to the base
class, but whose type is a pointer to a member of the derived class.

The current code only use the QMetaObject of the type coming from the
function type to look up the signal id. But if the signal was casted
to a pointer to member function of a derived type, then we also need to
look in the base classes

Change-Id: Ib98fc38f63942946acb34d9f83c100991d58e4e5
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2013-05-09 08:23:48 +02:00
Stephen Kelly
508ee5616b Add automatic container access registration for built-in containers.
Change-Id: I4d590c23e072994930922ff73367600f848fbcf0
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
2013-05-08 12:45:59 +02:00
Mitch Curtis
83315ce8b2 Revert QDateTime serialisation to pre-Qt 5 behaviour.
In Qt 5, I managed to break the guarantee that a deserialised local
datetime is the same time of day (potentially different UTC time),
regardless of which timezone it was serialised in. This happened after
I fixed QTBUG-4057 with If650e7960dca7b6ab44b8233410a6369c41df73a,
which serialised datetimes as UTC.

This patch reverts QDateTime serialisation to pre-Qt 5 behaviour to
restore the guarantee and consequently re-opens QTBUG-4057.

Change-Id: Iea877f7ed886f530b928067789b53534e89fe8cb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2013-05-08 10:00:29 +02:00
Stephen Kelly
620f788f86 Add QVariantList extraction from a QVariant with a sequential container.
Change-Id: Id9fac7bf47ed3fbb385222b25941215ac24b8b88
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
2013-05-08 06:02:53 +02:00
Stephen Kelly
01fb843af8 Add QVariant container iteration API.
A new set of classes is introduced for iterating over the contents
of a container within a QVariant without knowing the exact type of
the container, but with the guarantee that the element type within
the container is a metatype.

The implementation of the iterable interface uses
the stl-compatible container API so that we can also iterate over stl
containers, or any other container which also conforms to stl norms.

This enables the functionality in the bug report.

Task-number: QTBUG-23566

Change-Id: I92a2f3458516de201b8f0e470982c4d030e8ac8b
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
2013-05-08 06:02:45 +02:00
Christoph Schleifenbaum
f7b313e6d8 Core: Support for converting user defined QVariant types.
This patchs allows the user to convert defined QMetaType types like
MyType to be converted by using e.g. QVariant::toString(), mapping to
MyType::toString(). Also all the other QVariant::toXYZ() methods are
supported so far.

The patch adds static methods QMetaType::registerConverter supporting:
- implicit convertion
- conversion using member method of source type
- conversion using unary functor

Change-Id: I4f1db83d9c78bcc9df5c42f82f95cce0480cdcc3
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
Reviewed-by: Christoph Schleifenbaum <christoph.schleifenbaum@kdab.com>
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
2013-05-08 06:02:35 +02:00
El Mehdi Fekari
02679d93c4 QLocale: add autotest for French_Morocco locale
Change-Id: Ie489557342bf9ea571ba4070e8982b1a13fc7021
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-05-08 01:14:40 +02:00
Giuseppe D'Angelo
66ff3f7fa4 Add qt_hash(QStringRef) overload
This enables fixing a performance regression compared to Qt 4.
Also, add some qt_hash tests.

Change-Id: Id830e17dec99fb67e5930c80029ac2233b2f427e
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
2013-05-07 22:43:14 +02:00
Joerg Bornemann
28ee554b37 QProcess/Win: drain output pipes on process finish
If a process dies before all output is read into the internal buffer
of QProcess, we might lose data. Therefore we must drain the output
pipes like we already do in the synchronous wait functions.

Task-number: QTBUG-30843

Change-Id: I8bbc5265275c9ebd33218ba600267ae87d93ed61
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
2013-05-07 15:02:34 +02:00
Sergio Ahumada
db44b891fb Merge branch 'stable' into dev
Change-Id: Ica003a10ede86914bbbb062a2dc277a2ce39a259
2013-05-07 12:02:41 +02:00
Thiago Macieira
586fb6d632 Add some extra tests for QString::arg
Test locale-based formatting of numbers when we pass field width, base
and fill characters. This now tests the fact that we replace a '0' for
the locale's zero character.

Change-Id: Ib872a592fd9a754e3ef11495a9497a6947056631
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
2013-04-29 16:56:58 +02:00
Frederik Gladhorn
85e3c53e5c Merge remote-tracking branch 'origin/stable' into dev
Change-Id: I2a54058b64ac69c78b4120fdaf09b96e025a4c6c
2013-04-29 14:17:09 +02:00
Frederik Gladhorn
08585f02dc Merge "Merge remote-tracking branch 'origin/stable' into dev" into refs/staging/dev 2013-04-26 09:45:55 +02:00
Stephen Kelly
106dc410e9 Use variadic templates to mark function pointers as non-QObjects.
Change-Id: I4d4e7a0498ff8f5b834dae4008d1311838180036
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
2013-04-24 14:19:26 +02:00
J-P Nurmi
a7dc708eb5 Fix QAbstractItemModel::moveColumn()
Task-number: QTBUG-30346
Change-Id: I3d6dbe1e88bb5e2748eadabb2663f30be16f8d18
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
2013-04-23 13:35:31 +02:00
Frederik Gladhorn
4c231d5df3 Merge remote-tracking branch 'origin/stable' into dev
Change-Id: I059725e3b7d7ffd5a16a0931e6c17200917172b5
2013-04-22 16:35:43 +02:00
Janne Anttila
0775f88c66 Reduce qmetatype autotest build time for Windows CE.
qmetatype autotest build for WEC7 took several hours [1] See timestamps
03:51:13 and 07:44:52. The timestamped Jenkins log is only available
in Digia network. The corresponding log without timestamps is available
from [2].

Use same workaround for all Windows CE / WEC7 builds as currently
used for desktop MSVC2012.

[1]: http://qt-ci.digia.com/job/QtBase_stable_Integration/cfg=wince70embedded-armv4i-msvc2008_Windows_7/940/consoleFull
[2]: http://testresults.qt-project.org/ci/QtBase_stable_Integration/build_00940/

Change-Id: Ia21be8972d82c8d37073c9097b8d4094261e4126
Reviewed-by: Andreas Holzammer <andreas.holzammer@kdab.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
2013-04-17 19:48:38 +02:00
Janne Anttila
428efd2ebe Fix tst_qfile build for WEC7.
Windows Embedded Compact does not have drive letters like desktop
Windows => do not try to build drive letter related test code for WEC7.

Change-Id: I2c3659220a001510c0555e2dd773b4dd68e9c2cc
Reviewed-by: Andreas Holzammer <andreas.holzammer@kdab.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
2013-04-17 19:48:32 +02:00
Frederik Gladhorn
94758589fe Merge "Merge remote-tracking branch 'origin/stable' into dev" into refs/staging/dev 2013-04-17 10:28:21 +02:00
Thiago Macieira
b4ce49287f Make QBuffer::bytesAvailable() work
We don't need to keep an internal QBuffer position, we can just use the
one from QIODevice::pos(). It will keep track of goings ahead and
backwards for us, plus it will make the default bytesAvailable() work
out-of-the-box too.

This error was reported on IRC.

Change-Id: I8559e8ee56edaa01ca8732c1f1012082ebe3a3f2
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
2013-04-16 19:45:11 +02:00
Darryl L. Miles
5f9d58848a Json writer, support larger signed integers upto 2^53
Previously only 32bit signed integers were ensured to be supported by
JsonValue type via API but it is expected that a larger integer range
should be supported by a JSON implementation.

This commit brings the Qt implementation into parity with NodeJS
JSON.stringify() in respect of the JavaScript Number type.

Change-Id: If91153cb3b13ecc14c50da97055b35ce42f341e7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2013-04-12 22:33:23 +02:00
Darryl L. Miles
6348de8737 Json writer, emit full precision for floating point Number types
Previously Qt JSON writer would only emit 6 digits of precision as this
is the default with the formatter.

However with testing against NodeJS JSON.stringify() this behavior is
inconsistent with the defacto standard JSON implementation and conveys
a loss of precision.

Change-Id: Ie1845a6e0ee0b4c05f63ec0062f372e891855f0b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2013-04-12 22:33:19 +02:00
Darryl L. Miles
e2d614b6a9 Json writer, only emit floating point finite numbers, ignore INF/NaN
My interpretation of RFC4627, Section 2.4 "Numbers" of:
  Numeric values that cannot be represented as sequences of digits
   (such as Infinity and NaN) are not permitted.

I have also verified this matter with NodeJS JSON.stringify() that
emitting a null is consistent behavior with a JSON implementation
written in JavaScript.

Previously Qt would emit:
{
 plusInfinity: inf,
 minusInfinity: -inf,
 notANumber: nan
}

Which maybe turned into a string values of "inf", "-inf", "nan" by
the receiving parser.  Now it returns the JSON null value just like
NodeJS JSON.stringify().

Change-Id: I9f9c17f12b2606280806c47a9d90465c4ba5f786
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2013-04-12 22:33:13 +02:00
Frederik Gladhorn
aa3754d105 Merge remote-tracking branch 'origin/stable' into dev
Change-Id: Iee73c93067c5822d8dd51a8692e6da9df4ba49f5
2013-04-12 12:53:13 +02:00