Do not consume white-space after a token before the token has been
parsed, otherwise we end up with misleading offsets. This also fixes
a wrong error of illegal number in several cases.
Change-Id: I492ca4de0346a1d0ab73b1c23d7a72dba812664c
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Add better boundary checks and catch (hopefully all)
cases where invalid binary JSON could cause crashes.
Change-Id: I206510b7c5e3ba953802a5f46645878e65704ecc
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Adds a few missing parts of the conversion from QVariant to QJsonValue
after the introduction of the nullptr QVariant. The conversion the other
way is already implemented.
Change-Id: I8b25dec4b476c4761c5098a60944ff11c36f8bec
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Consistent with other Unix platforms, and internally consistent between tests,
as a lot of tests were already applying CONFIG -= app_bundle manually.
Change-Id: Icd2b7e1c08015b26137af60ff82fddbc753f0ff4
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
Move the different parts of configure.json/.pri into the libraries where
they belong.
Gui is not yet fully modularized, and contains many things related to
the different QPA plugins.
Done-with: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Change-Id: I6659bb29354ed1f36b95b8c69e7fce58f642053f
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Just one Q_FOREACH needed porting to C++11 range-for here.
Change-Id: I30ddd2a80cbb3245e23accc7843e67574fb2db17
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Use the new qtConfig macro in all pro/pri files.
This required adding some feature entries, and adding
{private,public}Feature to every referenced already existing entry.
Change-Id: I164214dad1154df6ad84e86d99ed14994ef97cf4
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Both were mapped to QVariant() before. Instead, use a null pointer
QVariant for a null JSON value.
[ChangeLog][QtCore][QJsonValue] QJsonValue(Null).toVariant() now returns
a QVariant of type QMetaType::Nullptr instead of an invalid QVariant.
Task-number: QTBUG-43077
Change-Id: Ife611f418583dbff542210bc8c5cd65201212a6e
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
It absence is just an oversight. The patch also adds test for the valid
inputs of the method.
[ChangeLog][QtCore][QJsonDocument] fromVariant can now take a QVariantHash argument.
Task-number: QTBUG-39751
Change-Id: I7e051413f930023db3cbb81452e77c56a7ceffe8
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
QXmlStreamReader also has QLatin1String overloads, which
greatly benefits parsers, since the vast majority of keys
in both JSON and XML are US-ASCII. This patch adds such an
overload to the JSON parser.
The value() function is all typical parsers need, so even
though many more QJsonObject functions taking QString could
benefit from the same treatment, value() is the single most
important one for read-only JSON access.
Add some more overloads, too, for functions that don't need
more internal scaffolding than value(). Requires adding a
dummy op[](QL1S) (forwarding to the QString overload) so as
not to make
QJsonObject json;
json[QLatin1String("key")]; // mutable
ambiguous between const op[](QL1S) and mutable op[](QString).
[ChangeLog][QtCore][QJsonObject] Added value(), op[] const,
find(), constFind(), contains() overloads taking QLatin1String.
Change-Id: I00883028956ad949ba5ba2b18dd8a6a25ad5085b
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Some entries were not updated and tests failed to succeed on platforms
which need to deploy content/testdata.
Change-Id: Ieb2b44c375b04cbaaecc1fb2303cc2478b86a100
Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com>
From Qt 5.7 -> tools & applications are lisenced under GPL v3 with some
exceptions, see
http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/
Updated license headers to use new GPL-EXCEPT header instead of LGPL21 one
(in those files which will be under GPL 3 with exceptions)
Change-Id: I42a473ddc97101492a60b9287d90979d9eb35ae1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
If the variant contains a known json type (value, array, object or
document), simply unwrap those. In the case of the json document
wrap the contained object/array into a QJsonValue.
This should be the expected behavior, and makes more sense than
returning a null QJsonValue.
Task-number: QTBUG-41234
Change-Id: Id084fc11220d51aaf78b7694fd0ebef1411f5c51
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Strings do not have to be overly specific to test parser function.
Change-Id: I345dfec7fb4b8004661f6757cfd53b428ad87b6b
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Move some code (like registrations of meta types) from init() to
initTestCase() in the process.
Change-Id: I57db5156647cfadab554fbed853b2e68b2815f3b
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@theqtcompany.com>
The file exists and it's listed in json.qrc (for Android) but it isn't
listed in TESTDATA. This is only a problem when the target is a another
system as is the case with Qt for QNX. One of the tests fails because
the file isn't deployed.
Noticed this while testing the changes for custom spacing of JSON
output.
Task-number: QTBUG-47437
Change-Id: I627592a5a225f50fdb8e3cdd6ac72dff43936ae5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Use character literals where applicable.
Change-Id: I1a026c320079ee5ca6f70be835d5a541deee2dd1
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
The keyword no longer has a meaning for the new CI.
Change-Id: Ibcea4c7a82fb7f982cf4569fdff19f82066543d1
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
- Replace Q[TRY]_VERIFY(pointer == 0) by Q[TRY]_VERIFY(!pointer).
- Replace Q[TRY]_VERIFY(smartPointer == 0) by
Q[TRY]_VERIFY(smartPointer.isNull()).
- Replace Q[TRY]_VERIFY(a == b) by Q[TRY]_COMPARE(a, b) and
add casts where necessary. The values will then be logged
should a test fail.
Tests from corelib/tools were omitted in this change.
Change-Id: I4c8786d33fcf429d11b2b624c7cd89c28cadb518
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
When using non latin keys, remove() could cause corruption
of the json object.
Task-number: QTBUG-42270
Change-Id: I7305e57ebb78630a9bf68bc4f831a6d1646abb79
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Qt copyrights are now in The Qt Company, so we could update the source
code headers accordingly. In the same go we should also fix the links to
point to qt.io.
Outdated header.LGPL removed (use header.LGPL21 instead)
Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing
combination. New header.LGPL-COMM taken in the use file which were
using old header.LGPL3 (src/plugins/platforms/android/extract.cpp)
Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license
combination
Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe
Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
Unify the behavior of the different operator<< by always using
QDebugStateSaver (appending an optional space at exit), and making
sure that the space(), nospace() setting isn't 'leaked'.
Change-Id: I38e4f82fa6f7419d8b5edfc4dc37495af497e8ac
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Add test data to resources.
Change-Id: Ib8a5688e7caab8434b8f0676f53a2a79ec94b264
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
Adds automatic conversion from QVariants with a QVariantHash to
QJsonValue and explicit methods for conversion between QVariantHash
and QJsonObject.
[ChangeLog][QtCore][QJsonObject] Added conversion to and from QVariantHash
Change-Id: I140ef881463acabaab2648e28209487d8ad18e0d
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
tst_qtjson.cpp(2711) : warning C4566: character represented by universal-character-name '\u2090' cannot be represented in the current code page (1252)
tst_qtjson.cpp(2712) : warning C4566: character represented by universal-character-name '\u2090' cannot be represented in the current code page (1252)
tst_qtjson.cpp(2713) : warning C4566: character represented by universal-character-name '\u2090' cannot be represented in the current code page (1252)
Task-number: QTBUG-41100
Change-Id: I193dc48236bdd3857657a5684178630f0e1dab6d
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
This reverts commit 20cf632ad5. The commit
produced to many problems during statics destruction. For example
causing QtCreator crash (QTBUG-40987).
Change-Id: Ib52f6a449c2d84deab2de792559a6a065ca45e8d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
A well formed JSON document is not allowed to contain
trailing garbage at the end. Don't accept this in the
parser.
Task-number: QTBUG-40062
Change-Id: I0a09dbd099a8c643f58023342546c4e67d026fec
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
The comparison operators between QJsonPrivate::String
and QJsonPrivate::Latin1String weren't all correct, leading
to wrong sorting of keys in QJsonObjects when the keys were
outside of the latin1 range and resulting lookup errors.
Task-number: QTBUG-41100
Change-Id: Idceff615f85d7ab874ad2a8e4a6c1ce8c2aa0f65
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
The iterators for QJsonArray and QJsonObject are currently lacking an
operator-> definition. Unfortunately it is not possible to do in clean
way without redefining either the iterators or QJsonValueRef class.
This patch instead adds two fake pointer classes that are only used
to handle the operator-> return value.
Task-number: QTBUG-29573
Change-Id: Ief785a6afbbedc9e89cf3b6f3958c2c755997a66
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
It allows to create a QJsonObject instance in C++ by using
initializer list of pairs QString QJsonValue, for example:
QJsonObject o = {{"property1", 1}, {"property2", 2}};
[ChangeLog][QtCore][QtJson] QJsonObject now supports
C++11 initializer lists.
Task-number: QTBUG-26606
Change-Id: I67af881e175f427e563e685336c48a5f8466b476
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
QJsonValue, while comparing two QJsonArrays, should consult also length
of the arrays, because a different than null base pointer doesn't mean
that an array is not empty.
Change-Id: If76739355a4e74b842e836289565f98d95c006d5
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
QJsonValue, while comparing two QJsonObjects, should consult also length
of the objects, because a different than null base pointer doesn't mean
that an object is not empty.
Change-Id: Ibee1849ef9fed15d32f2c8f2aad9b053846e46b7
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Before this change such code:
QJsonObject o;
o["blah"];
would create property "blah" and assign null value to it, while
this code:
const QJsonObject o;
o["blah"];
would not. The change unifies the confusing behavior. Now reading
a non-existing property, is not causing a property to be added
in any visible way.
Internally QJsonObject stores a special hash of undefined, but
referenced values. Such reference is supposed to not live long,
only to the first compacting or assignment.
Change-Id: Ib022acf74ff49bad88d45d65d7093c4281d468f1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
The operator should always return an undefined values for an empty
object
Change-Id: Ic38f7660d77c64b2d001967bc5109df4185db74a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
It allows to create a QJsonArray instance in C++ by using
a similar expression to JSON. For example:
QJsonArray a = {1, 2, 4};
[ChangeLog][QtCore][QtJson] QJsonArray now supports
C++11 initializer lists.
Task-number: QTBUG-26606
Change-Id: Icc352e518d9649d24176c89e7113d200d5c50b0d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Currently QJsonValue and QJsonValueRef behave differently in
regard to the default values leading to confusion compile errors
depending on which of the two types one is actually using. Before
this change it was possible to write:
QJsonValue value = jsonObject["item"];
QString name = value.toString(QStringLiteral("default"));
but not:
QString name = jsonObject["item"].toString(QStringLiteral("default"));
Change-Id: Id1185acf339aa3a91e97848e85d068f84552df71
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
Extending this to stock QNX as well since it is not
BlackBerry 10 specific.
- tst_QNumeric::floatDistance()
- tst_QNumeric::floatDistance_double()
- tst_QtJson::testNumbers_2()
- tst_QtJson::toJsonLargeNumericValues()
- tst_QtJson::parseNumbers()
Task-number: QTBUG-37066
Change-Id: If0e5d4fbefac5e8a0efed8ef8b1b7655ff6e7766
Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
- QVariant can store (U)Int, (U)LongLong, Float and Double numbers.
Previously, QJsonValue::fromVariant() converted Floats into Strings
while converting the others to Doubles.
- Add unit tests for QJsonValue::fromVariant()
[ChangeLog][QtCore][JSON] QJsonValue::fromVariant() will now convert
single-precision Floats into Doubles instead of Strings
Change-Id: I457adbe29c37ada611d1c6d711c42866d63d4024
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
These tests seem to fail because denormalized numbers are not
supported on QNX yet, so marking them as expected failures.
- testNumbers_2()
- toJsonLargeNumericValues()
- parseNumbers()
Task-number: QTBUG-37066
Change-Id: Ifec95b936fb70253395dee4d1ca18e85870486a3
Reviewed-by: Fabian Bumberger <fbumberger@rim.com>