summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qvariant.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QVariant: Fix isNull() == true after downcasting QObject*Timo Lang2019-03-211-0/+2
| | | | | | | | | | [ChangeLog][QtCore][QVariant] Fixed a bug that caused isNull() to be true after downcasting a QObject* payload using convert(). Fixes: QTBUG-73196 Change-Id: Ifda15952f873d7142c95609b69ac424bbf16b723 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
* Add qFpClassify() to mirror std::fpclassify()Edward Welbourne2019-03-191-3/+3
| | | | | | | | | | | | The rules of std don't permit us to add an overload for fpclassify(qfloat16), so we need our own equivalent that we *can* overload. Deploy it in the few places we use fpclassify(). Extended qnumeric's testing to cover qFpClassify(). Change-Id: Ie5a0a5cc24599d1571404c573d33c682b0d305a5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* QtCore: replace null and nullptr with \nullptr in documentationChristian Ehrlicher2019-02-181-2/+2
| | | | | | | Replace null and '\c nullptr' with \nullptr in the documentation. Change-Id: Ib9e0cfc2eb2830b213e6523773603d56180b0998 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* qtlite: Fix build libs with -no-feature-regularexpressionMikhail Svetkin2019-01-271-0/+4
| | | | | Change-Id: I427ff1f8f4986fbf466aba60a9d3de614c1e006f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Treat shorts as int in QVariant::canConvert()Allan Sandfeld Jensen2018-11-011-3/+9
| | | | | | | | | Follow the pattern of char and float, and treat shorts as a more generic type in QVariant::canConvert() Task-number: QTBUG-60914 Change-Id: Ib1cc7941ee47cb0fc0098f22f98a03cd6f6b63fe Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/5.11' into 5.12Liang Qi2018-09-271-4/+4
|\ | | | | | | | | | | | | | | Conflicts: src/corelib/global/qconfig-bootstrapped.h src/widgets/util/qcompleter.cpp Change-Id: I4f44f0f074982530f2f2e750ce696230b2754cf3
| * Modernize the "datestring" featureLiang Qi2018-09-241-4/+4
| | | | | | | | | | | | Change-Id: I2236a456fe3758d9054b22e36fe6316f3522d533 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | Fix ASAN error about new-delete-size-mismatch in QVariantSimon Hausmann2018-08-071-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We allocate the variant's PrivateShared for custom types with space for the actual custom type right after that, using operator new to allocate the memory and a new calls for the constructors. However to free the memory we merely call delete on the private shared, which upsets ASAN because the size passed to operator delete is the size of the private shared, which is not the same as the size that was provided for the returned address. This is easily fixable by calling the destructor explicitly and calling operator delete with just the pointer. Change-Id: I50afbe0e8afc875c0876e85e02689dcbdc152633 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | CBOR: Complete the conversions between CBOR, JSON and Qt meta typesThiago Macieira2018-07-041-5/+338
| | | | | | | | | | | | Change-Id: I56b444f9d6274221a3b7fffd150d3130db6ef1a0 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Metatype: make the Qt CBOR value-like types built-in meta typesThiago Macieira2018-07-041-1/+4
| | | | | | | | | | | | | | | | This change only adds them to the registry and reserves the IDs. The next commit will handle conversions. Change-Id: I56b444f9d6274221a3b7fffd150d2d49f40940c2 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* | Merge remote-tracking branch 'origin/5.11' into devQt Forward Merge Bot2018-04-101-43/+48
|\| | | | | | | Change-Id: I0120f804522c0c652e9537b6e9fe08189f071ed2
| * Doc: Update QVariant::toString description, update see also linksPaul Wicking2018-04-091-43/+48
| | | | | | | | | | | | | | | | | | | | Change the toString description to reflect that the listed types are not exclusive, and update see also link to link to the canConvert method that includes conversion table. Task-number: QTBUG-67174 Change-Id: I3ad2889c98a235995b94a2d0496a6fb8c024b7bb Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* | QVariant: Avoid a memory allocation with custom typesOlivier Goffart2018-04-081-3/+10
|/ | | | | | | | | | Store big or un-movable custom type within the same memory region as the QVariant::PrivateShared. Makes tst_qvariant::bigClassVariantCreation 33% faster Change-Id: I60a757d1f0a9a02cf9ac36fb53a72426b2f8cfa8 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
* Make sure we can build with -no-feature-itemmodelUlf Hermann2018-03-211-23/+33
| | | | | | | Various pieces of code have to be disabled in this case. Change-Id: I83b133f17e9f024016a79c9103293627185449d2 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
* Modernize the "regularexpression" featureUlf Hermann2018-03-201-7/+9
| | | | | | | | | | | | | Use QT_CONFIG(regularexpression), disentangle it from QT_BOOTSTRAPPED, switch it off in the bootstrap build, remove the #ifdefs from qregularexpression.{h|cpp}, and add QT_REQUIRE_CONFIG(regularexpression) to the header. qregularexpression.{h|cpp} are already correctly excluded in tools.pri if !qtConfig(regularexpression). Change-Id: I21de154a6a118b76f99003d3acb72ac1e220d302 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
* doc: Make fromStdVariant() appear in the QVariant docsMartin Smith2018-03-141-1/+1
| | | | | | | | | | | | This function was not appearing in the QVariant docs because the \fn command was wrong and because clang was not seeing the declaration in qvariant.h in the first place. With this update, the function does appear in the docs, but it's signature is not correct because clang can't find a definition for std::variant<Types...>, which probably means it doesn't have the most recent declarations in the std namespace. Change-Id: I7912ff333e5d4a8619461dd3ab7ee34bcd8f2289 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* QVariant: Add missing conversion from QJsonValue to double & floatThiago Macieira2018-02-111-0/+4
| | | | | Change-Id: I56b444f9d6274221a3b7fffd150d2ff1df5228bc Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Merge remote-tracking branch 'origin/dev' into 5.11Liang Qi2018-02-101-0/+13
|\ | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/tools/qvarlengtharray.qdoc src/corelib/tools/qvector.qdoc Resolved documentation changes in favor of 017569f702b6dd0, which keeps the move overloads along with its const-ref sibling. Change-Id: I0835b0b3211a418e5e50defc4cf315f0964fab79
| * Add support for converting from std::variantAllan Sandfeld Jensen2018-01-251-0/+13
| | | | | | | | | | | | | | | | Adds inline handling of the C++17 type std::variant, so the type will be resolved if converted into a QVariant. Change-Id: I31809d70d7f347277389d42a3695836ec7a32d02 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QVariant: convert QDateTime and QTime to string with millisecondsThiago Macieira2018-02-051-2/+2
|/ | | | | | | | | | | | | | This way, it's lossless. This commit is a cherry-pick of ab1e50757454b5afda2f6dec52d2eb16a32d4798, which was reverted. [ChangeLog][QtCore][QVariant] Conversions of QDateTime to strings now contain the millisecond components. Change-Id: I5e421e32396d44e4b39efffd150b744e40fff3a1 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
* doc: Correct clang parsing errors in qvariant.hMartin Smith2018-01-091-0/+35
| | | | | | | | | | | | Some old uses of Q_QDOC to prevent the old qdoc C++ parser from seeing declarations it didn't need to see were preventing clang from seeing declarations it did need to see. These have been removed, and some internal documentation has been added to account for some declarations that suddenly became public but should not be seen in the Qt API. Change-Id: Iccf423e5cf8767f0a271150ab59bea54cf90ac46 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* doc: Correct remaining qdoc warnings in qvariant.cppMartin Smith2018-01-041-8/+8
| | | | | | | clang required adding template clauses to several \fn commands. Change-Id: I1ee9855c626b41e499392c05160df01daa5c0618 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Merge remote-tracking branch 'origin/5.9' into 5.10Liang Qi2017-09-201-40/+52
|\ | | | | | | | | | | | | | | | | | | Conflicts: src/plugins/styles/mac/qmacstyle_mac.mm src/widgets/util/qcompleter.cpp src/widgets/widgets/qmainwindowlayout.cpp src/widgets/widgets/qmdisubwindow.cpp Change-Id: If0e96981af07ce36ac68f2e69211bc2120f93973
| * Optimize QVariant::cmp()Lars Knoll2017-09-141-40/+49
| | | | | | | | | | | | | | | | | | Don't always copy the variants that we want to compare. This can in some cases be a relatively expensive operation. Change-Id: I2b3fd246ac136b19d8a8d281fbdcfb0417c8fb6c Reviewed-by: Sean Harmer <sean.harmer@kdab.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
| * Improve performance of QVariant::canConvert()Lars Knoll2017-09-131-0/+3
| | | | | | | | | | | | | | | | Add an early check if both types are the same. Change-Id: If6fc60a58fce641521c083bf920e72bf3d2d4c28 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Implement conversion from nullptr QVariant to QString and QByteArrayAllan Sandfeld Jensen2017-08-041-2/+8
| | | | | | | | | | | | | | | | | | A nullptr QVariant should become a null QString or QByteArray, since null strings have previous in our APIs represented the null value in the absence of a dedicated null metatype. Change-Id: I3b8f6386ece314d7c196959fbcf042c4fe0508a0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QVariants of null pointers should be nullAllan Sandfeld Jensen2017-08-041-4/+15
| | | | | | | | | | | | | | | | | | | | | | Changes the QVariant::isNull() implementation for pointer types so they return true if null. [ChangeLog][QVariant] QVariants containing pointers will now return true on isNull() if the contained pointer is null. Change-Id: I8aa0dab482403837073fb2f376a46126cc3bc6b2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Allow conversion of QVariants with real null valuesAllan Sandfeld Jensen2017-08-021-12/+22
| | | | | | | | | | | | | | | | | | Update documentation to be clearer on the special null variant state with no value as opposed to a variant with a null value, and only block conversions of the former. Change-Id: I24fd50285414e049de87de54a63700a89bd5adf1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Improve symmetry of variant json conversionsAllan Sandfeld Jensen2017-07-251-2/+103
|/ | | | | | | | Make QVariant::toJsonValue do conversions as well as QJsonValue::fromVariant. Change-Id: I175d43677061470691e2e0104a800be355fbbd3d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Handle conversion and comparison between qvarianthash and qvariantmapAllan Sandfeld Jensen2017-07-111-0/+12
| | | | | | | | | QVariant claims to be able to QVariantHash and QVariantMap, but the actual conversion implementation is missing. Task-number: QTBUG-61471 Change-Id: I0cba74642aa77dc423effed289bc7619922a89eb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QVariant: Print a warning when deserialized user type is unknownMichael Winkelmann2017-07-051-0/+1
| | | | | | | | The deserialized user type is now shown to the user to figure which QMetaType registration is missing. Change-Id: I4b7624827e479b1bea67065ce3542183b7355165 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
* Doc: Fix a typo in QVariant::toPoint docsLeena Miettinen2017-06-011-1/+1
| | | | | | Task-number: QTBUG-61050 Change-Id: I517f95df9d1019d37b6484e00220e8e325ee2ecf Reviewed-by: Martin Smith <martin.smith@qt.io>
* QVariant: implement QByteArray ↔ QUuid conversionv5.9.0-beta2Marc Mutz2017-04-141-5/+12
| | | | | | | | | | Seems like an obvious omission. [ChangeLog][QtCore][QVariant] Can now convert QUuid to and from QByteArray, not just QString. Change-Id: Ib56ae86ca0c27adaf1e095b6b85e64fe64ea8d18 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/5.8' into 5.9Liang Qi2017-04-121-3/+5
|\ | | | | | | Change-Id: I3bd83a839b16822035ed56a5cffe77bd6bc3f08d
| * QVariant: fix docs regarding QUuidMarc Mutz2017-04-101-3/+5
| | | | | | | | | | | | | | | | - toUuid(): QUuid is a built-in type, so use type(), not userType() - canConvert()/toUuid(): QUuid converts to and from QString Change-Id: I5262ff7ab093040cb943b6ab9cfffe95491d2b9b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/5.8' into 5.9Liang Qi2017-02-081-1/+11
|\| | | | | | | | | | | | | | | Conflicts: configure.json mkspecs/win32-icc/qmake.conf Change-Id: Ibf40546b024d644c7d9ed490bee15b82597f4d3f
| * QVariant: don't do fuzzy comparisons with NaN and infinitiesThiago Macieira2017-01-311-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | There was a test that tested this, but was wrong. [ChangeLog][QtCore][QVariant] Fixed a bug that caused wrong results for comparisons of QVariants containing either NaN or infinite numbers. Task-number: QTBUG-56073 Change-Id: I33dc971f005a4848bb8ffffd1475d29d00dd1b7f Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/5.8' into devLiang Qi2017-01-251-1/+1
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf mkspecs/common/msvc-desktop.conf mkspecs/common/msvc-version.conf mkspecs/common/winrt_winphone/qmake.conf mkspecs/features/mac/default_post.prf mkspecs/features/mac/sdk.prf mkspecs/features/qt.prf mkspecs/features/uikit/default_post.prf mkspecs/features/winrt/default_pre.prf mkspecs/winphone-arm-msvc2013/qmake.conf mkspecs/winphone-x86-msvc2013/qmake.conf mkspecs/winrt-arm-msvc2013/qmake.conf mkspecs/winrt-x64-msvc2013/qmake.conf mkspecs/winrt-x86-msvc2013/qmake.conf qmake/generators/win32/msvc_vcproj.cpp src/gui/kernel/qwindowsysteminterface.cpp src/network/kernel/qhostaddress.cpp src/plugins/platforms/mirclient/qmirclientplugin.cpp src/plugins/platforms/mirclient/qmirclientplugin.h src/widgets/util/qsystemtrayicon.cpp tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp tools/configure/Makefile.mingw tools/configure/Makefile.win32 Done-with: Jake Petroules <jake.petroules@qt.io> Done-with: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Change-Id: I4be3262d3994e11929d3b1ded2c3379783797dbe
| * Link QVariant class documentation to the Creating Custom Qt Types articleKavindra Palaraja2016-12-281-1/+1
| | | | | | | | | | | | | | | | The article does answer the questions asked in the bug. Task-number: QTBUG-56629 Change-Id: Ib8bac0acf45bc10598fc47feb6dd73005b5ad040 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/5.8' into devLiang Qi2016-12-131-2/+2
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: configure qmake/Makefile.unix.macos qmake/Makefile.unix.win32 qmake/generators/win32/msvc_vcproj.cpp src/3rdparty/pcre/qt_attribution.json src/corelib/io/qsettings.cpp src/corelib/kernel/qdeadlinetimer.cpp src/platformsupport/kmsconvenience/qkmsdevice.cpp src/platformsupport/kmsconvenience/qkmsdevice_p.h src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.cpp src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h tests/manual/qstorageinfo/printvolumes.cpp tools/configure/configureapp.cpp Change-Id: Ibaabcc8e965c44926f9fb018466e8b132b8df49e
| * QVariant: optimize convert() for bool caseAnton Kudryavtsev2016-12-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | Do not create QByteArray from const char* to compare with other QByteArray, because there is an overloaded operator==. So avoid needless allocations. Reorder condition, because isEmpty() method is cheaper than string compare. Change-Id: I8d2c8a0fb247528d9ce485007431167372d62bff Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | doc: clangqdoc must see class QWinEventNotifierMartin Smith2016-11-191-1/+1
|/ | | | | | | | | | | | clangqdoc must parse the declaration for QWinEventNotifier for all platforms, not just for Q_OS_WIN, so Q_CLANG_QDOC must be tested as well. Plus the qdoc comment for an invisible static function is converted to a non-qdoc comment in qvariant.cpp Change-Id: Ic41731decca55b3be837f9c5f832310513773e60 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QVariant to QJsonValue::Null conversionAllan Sandfeld Jensen2016-11-081-0/+1
| | | | | | | | | 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>
* Merge dev into 5.8Oswald Buddenhagen2016-08-221-1/+3
|\ | | | | | | Change-Id: I41ee7b50534b01cf042bed8bb8824ba2e5026a29
| * Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-08-131-1/+1
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/global/qglobal.cpp src/corelib/io/qsettings.cpp src/corelib/itemmodels/qstringlistmodel.cpp tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp Change-Id: I1c6c306ef42c3c0234b19907914b19da706b4a03
| | * Fix typo (word repetition) in documentationFrederik Schwarzer2016-08-121-1/+1
| | | | | | | | | | | | | | | Change-Id: I1c8785e39f28f94846126fc45b875e6425a4ce12 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
| * | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-08-051-0/+2
| |\| | | | | | | | | | | | | | | | | | | Conflicts: tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp Change-Id: I6f3878b204464313aa2f9d988d3b35121d4d9867
| | * Fixed Bug in QVariant comparison when containing QStringListsClemens Sielaff2016-08-031-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As it were, QStringLists were not handled explicitly when comparing QVariants. If both QStringLists contained only a single entry, they were treated as QStrings - if both QStringLists were empty, there were equal (correctly so) - but if one of the QStringLists had more than one entry, the compare function fell through to returning always 1. As discussed here: https://stackoverflow.com/a/38492467/3444217 Added rich comparison tests for all non-numerical, non-recursive QVariants that support them (except QModelIndex and QPersistentModelIndex) Task-number: QTBUG-54893 Change-Id: Icc5480d9ba056ee5efe83da566c5829caa1509d7 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
* | | Support C++17 fallthrough attributeAllan Sandfeld Jensen2016-08-191-3/+3
|/ / | | | | | | | | | | | | | | | | Replaces our mix of comments for annotating intended absence of break in switches with the C++17 attribute [[fallthrough]], or its earlier a clang extension counterpart. Change-Id: I4b2d0b9b5e4425819c7f1bf01608093c536b6d14 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-05-191-1/+21
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: configure src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp src/network/access/qnetworkaccessmanager.cpp src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.h src/widgets/widgets/qlineedit_p.cpp src/widgets/widgets/qlineedit_p.h src/winmain/winmain.pro tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp tests/auto/dbus/qdbusconnection/tst_qdbusconnection.h tests/auto/testlib/selftests/expected_cmptest.teamcity tests/auto/testlib/selftests/expected_cmptest.txt tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp tools/configure/configureapp.cpp Change-Id: Ib9997b0d0f91946e4081d36c0c6b696c5c983b2a