summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qvariant_p.h
Commit message (Collapse)AuthorAgeFilesLines
* Merge remote-tracking branch 'origin/5.6' into devLiang Qi2016-01-211-47/+39
|\ | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qiodevice_p.h src/corelib/kernel/qvariant_p.h src/corelib/tools/qsimd.cpp src/gui/kernel/qguiapplication.cpp tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp Change-Id: I742a093cbb231b282b43e463ec67173e0d29f57a
| * Fix GCC 6 warning about placement-new operator on too little spaceThiago Macieira2016-01-121-18/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GCC 6 is able to detect when you use a placement new of an object in a space that is too small to contain it. qvariant_p.h: In instantiation of ‘void v_construct(QVariant::Private*, const T&) [with T = QRectF]’: qvariant_p.h:142:9: error: placement new constructing an object of type ‘QRectF’ and size ‘32’ in a region of type ‘void*’ and size ‘8’ [-Werror=placement-new] new (&x->data.ptr) T(t); ^~~~~~~~~~~~~~~~~~~~~~~ This happens even for the false branch of a constant expression (the enum). So split the v_construct function in two pairs, one pair for being able to use the internal space and one pair not so. Change-Id: Ibc83b9f7e3bc4962ae35ffff1425ed898f279dea Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
| * QVariant: use v_construct instead of duplicating logicThiago Macieira2016-01-121-31/+4
| | | | | | | | | | | | | | | | | | v_construct does what we want, so use it. This is required for the next commit, which solves a GCC 6 warning issue. Change-Id: Ibc83b9f7e3bc4962ae35ffff1425ed5f035f631a Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
| * QVariant: make sure to default-initialize in v_constructThiago Macieira2016-01-121-1/+1
| | | | | | | | | | | | | | | | | | | | Otherwise it's possible to get garbage for primitive types (trivially constructible) under some conditions. Change-Id: I408dcb81ba654c929f25ffff142885fc62395948 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | Updated license headersJani Heikkinen2016-01-151-14/+20
| | | | | | | | | | | | | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I046ec3e47b1876cd7b4b0353a576b352e3a946d9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* | QVariantIsNull: remove the non-C++11 implementationOlivier Goffart2015-11-161-39/+0
|/ | | | | | | | decltype is required now Change-Id: I69173127bd35f1d29945c8cfa47e1fbf1479c14d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
* Use QTypeInfo<T>::isRelocatable in QVariantThiago Macieira2015-09-241-1/+1
| | | | | Change-Id: Ib306f8f647014b399b87ffff13f1f01c40dc3ef7 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Update copyright headersJani Heikkinen2015-02-111-7/+7
| | | | | | | | | | | | | | | | | | 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>
* QVariant: attempt to work around an ICE on linux-arm-gnueabi-g++ (Ubuntu ↵Marc Mutz2015-01-161-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 11.10) with constexpr QSizePolicy This is the error: src/corelib/kernel/qvariant_p.h: In constructor ‘QVariantPrivateSharedEx<T>::QVariantPrivateSharedEx() [with T = QSizePolicy]’: src/corelib/kernel/qvariant_p.h:107:61: internal compiler error: in gimplify_init_ctor_eval, at gimplify.c:3560 There are two things fishy in this file: 1. Use of the unnamed namespace in a file that gets included in different libraries. While not technically undefined behavior, it may become so when used in the implementation, which it is. 2. Missing explicit initialization of a member of QVariantPrivateSharedEx. This is just a wild guess, because the ICE happens in that line. That class itself is quite smelly, because the address of an object is taken before the lifetime of the object begins. A fix would be to store the object in a wrapper class from which QVPSEx inherits _first_, but then a cast from QVPSEx to QVariant::PrivateShared would require pointer adjustments, and I didn't look through all the code to determine whether that would be an issue. Having been bitten by this sometime ago: https://marcmutz.wordpress.com/private-practice/private-practice-taming-templates/#edit-20111128 I opted to do these easy changes first to see whether they already fix the ICE. Change-Id: Ic15fd928b3dff2318c425c915b2dab5e54254d71 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* Make use of the internal space for enum in QVariantOlivier Goffart2013-11-081-1/+1
| | | | | | | | Enums are movable even if they have not been tagged as such, and therefore can safely make use of the internal storage. Change-Id: I3bec8556bfeb4a07cb30d918f8d1dd2565d6d94a Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* Fix compilation with ICC 13.1: the MSVC 2005 & 2008 code is badThiago Macieira2013-06-261-1/+1
| | | | | | | | | qvariant_p.h(226): error: name followed by "::" must be a class or namespace name template<class C> static Yes test(char (*)[(&C::isNull == 0) + 1]); ^ Change-Id: I42eef44d46ca0fb7aac8f82150e917c4fb912b15 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
* Whitespace cleanup: remove trailing whitespaceAxel Waggershauser2013-03-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Remove all trailing whitespace from the following list of files: *.cpp *.h *.conf *.qdoc *.pro *.pri *.mm *.rc *.pl *.qps *.xpm *.txt *README excluding 3rdparty, test-data and auto generated code. Note A): the only non 3rdparty c++-files that still have trailing whitespace after this change are: * src/corelib/codecs/cp949codetbl_p.h * src/corelib/codecs/qjpunicode.cpp * src/corelib/codecs/qbig5codec.cpp * src/corelib/xml/qxmlstream_p.h * src/tools/qdoc/qmlparser/qqmljsgrammar.cpp * src/tools/uic/ui4.cpp * tests/auto/other/qtokenautomaton/tokenizers/* * tests/benchmarks/corelib/tools/qstring/data.cpp * util/lexgen/tokenizer.cpp Note B): in about 30 files some overlapping 'leading tab' and 'TAB character in non-leading whitespace' issues have been fixed to make the sanity bot happy. Plus some general ws-fixes here and there as asked for during review. Change-Id: Ia713113c34d82442d6ce4d93d8b1cf545075d11d Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-221-24/+24
| | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: If1cc974286d29fd01ec6c19dd4719a67f4c3f00e Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* QtGlobal: remove Q_DECL_FINAL_CLASSMarc Mutz2012-08-261-3/+3
| | | | | | | | | | | Now that qvariant_p.h's HasIsNullMethod check is fixed so that it doesn't require Q_COMPILER_DECLTYPE anymore to be able to deal with final classes, there's no point in distinguishing Q_DECL_FINAL and Q_DECL_FINAL_CLASS anymore, so remove the latter. Change-Id: I31de5b63e7d2e44171a13e928997c946d93e05c9 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* QVariant: make the HasIsNullMethod check work across all compilers (maybe)Marc Mutz2012-08-261-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | Currently, we have a C++11 version that requires Q_COMPILER_DECLTYPE support, and can deal with final classes, and a C++98 version that doesn't require any C++11 features, but fails on final classes. What we're missing is a version that works for MSVC v8 and v9 (2005 and 2008), which sport the 'sealed' non-standard keywords but lack decltype support. So far, we tried to solve the problem by making class-level final special (Q_DECL_FINAL_CLASS), not defining that macro for these two compilers, even though we did define Q_DECL_FINAL, the method-level keyword. This new formulation, taken from http://stackoverflow.com/a/9655327/134841 supposedly supports all compilers with a minor #ifdef for MSVC which doesn't like applying sizeof() the way we do. However, testing has shown this to blow up on OSX. So we use the less intrusive approach: add this variant as a third version, only used by VC 2005 and 2008. Change-Id: If1945f8a6e9ed36cb68212fa781d5e29eb2a082d Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Merge remote-tracking branch 'origin/master' into api_changesOswald Buddenhagen2012-04-101-0/+1
|\ | | | | | | | | | | | | | | | | | | 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
| * Fix "unused variable" warning in QVariant header.Morten Sorvig2012-03-301-0/+1
| | | | | | | | | | Change-Id: Ia70ee372e277b1f95b893c461820fe97f381b8b1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Crash fix in ~QVariantJędrzej Nowacki2012-03-211-1/+0
| | | | | | | | | | | | | | | | QVariant handlers can not be unregistered. We are not able to guarantee that such operation is safe and we do not want to. Change-Id: Id9a12e6a8c750110e4a08eab1de3e07e5c408675 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Remove a dead code from QVariant.Jędrzej Nowacki2012-03-191-9/+26
| | | | | | | | | | | | | | Remove some "safety" code, but essentially it was a dead code. Change-Id: Ie19c29d4cce8b72be5dbaca53c03adc63e8c3dc5 Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
* | Merge "Merge remote-tracking branch 'origin/containers' into api_changes" ↵Friedemann Kleint2012-03-091-6/+23
|\ \ | | | | | | | | | into refs/staging/api_changes
| * | Introduce QMetaType::UnknownType.Jędrzej Nowacki2012-03-021-6/+23
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QMetaType::Void was ambiguous, it was pointing to a valid type (void) and in the same time it was signaling errors in QMetaType. There was no clean way to check if returned type was valid void or some unregistered type. This feature will be used by new QMetaObject revision which will store type ids instead of type names. So it will be easy to distinguish between: void mySlot(); MyUnregisteredType mySlot(); Change-Id: I73ff097f75585a95e12df74d50c6f3141153e771 Reviewed-by: Kent Hansen <kent.hansen@nokia.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* / QVariant: fix HasIsNullMethod for final classesMarc Mutz2012-03-081-1/+21
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | HasIsNullMethod uses the accepted C++98 idiom to check for members that might be inherited from baseclasses. The technique, however, requires inheriting from the type-under-test, which fails for C++11 final classes. Fortunately, under C++11 we have much better support for static type introspection: sfinae for expressions. We use this here (see decltype() use in qvariant_p.h) to write a C++11 version of HasIsNullMethod that works with final classes, too. However, since this technique required decltype() support in the compiler, Q_DECL_FINAL can no longer be used for both method and class markup. So we declare a new Q_DECL_FINAL_CLASS which is only set iff the compiler supports decltype(), too. MSVC 2005 and 2008 support a non-standard, but sufficiently compatible, version of override/final, but no decltype(). A later patch will use MSVC 'override/'sealed' to implement Q_DECL_{OVERRIDE,FINAL} for these compilers, but I currently don't see a version of HasIsNullMethod that could support these two, so the split off of Q_DECL_FINAL_CLASS is in anticipation of that commit. If someone _does_ find an implementation of HasIsNullMethod that works on MSVC2005 and 2008 sealed classes, then it's a simple matter of s/Q_DECL_FINAL_CLASS/Q_DECL_FINAL/g. This code has been tested on GCC 4.7 (prerelease) and GCC 4.8 (prerelease). Change-Id: I8700c8307d79a74d45fef0aec1c6027b4a922a43 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Simplify QMetaTypeSwitcher.Jędrzej Nowacki2012-02-271-1/+2
| | | | | | | | | | We do not need to distinguish between different types in the switcher. Before this patch it was not possible to overload DelegateObject::delegate with a pointer type. Now it is fixed. Change-Id: Icd73a53e73e5e66b1b6f6407ba4e0f79e584d930 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Rename QMetaTypeSwitcher::UnknownType to NotBuiltinType.Jędrzej Nowacki2012-02-231-3/+3
| | | | | | | | UnknownType suggest that a type is unknown to QMetaType, but QMetaTypeSwitcher is not checking for custom types. Change-Id: I6b8b692e0f20bed286c713672b35fb15757d389e Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Remove use of Q_BROKEN_DEBUG_STREAM.Stephen Kelly2012-02-221-1/+1
| | | | | | | | No supported compiler defines it, and it was not used consistently so it didn't work anyway. Change-Id: Icc9e911e22daaedaee3d9316c15d19be26cd2e72 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix position of a comment.Jędrzej Nowacki2012-02-081-3/+2
| | | | | | | The comment was wrongly placed. It describes v_cast function. Change-Id: I2390e4bf1fc19136bbbecbae4be83d5320ca244f Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
* Align QVariant::UserType and QMetaType::UserJędrzej Nowacki2012-02-071-14/+1
| | | | | | | | | | | | | | | | | | | | | | | There is no point in keeping separate values which should mean the same. QVariant::UserType was used also to construct a valid, null QVariant, containing an instance of unknown custom type. The concept was strange and useless as there was no operation that could be done on such QVariant. Therefore it was dropped. Please note that the patch slightly changes behavior of different functions accepting a type id as parameter. Before QVariant::UserType was an invalid type from QMetaType perspective (id 127 was not assigned to any built-in type), but QMetaType::User points to the first registered custom type. Change-Id: I5c7d541a9affdcdacf53a4eda2272bdafaa87b71 Reviewed-by: Kent Hansen <kent.hansen@nokia.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: João Abecasis <joao.abecasis@nokia.com> Reviewed-by: Andrew Stanley-Jones <andrew.stanley-jones@nokia.com> Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
* Remove "All rights reserved" line from license headers.Jason McDonald2012-01-301-1/+1
| | | | | | | | | | As in the past, to avoid rewriting various autotests that contain line-number information, an extra blank line has been inserted at the end of the license text to ensure that this commit does not change the total number of lines in the license header. Change-Id: I311e001373776812699d6efc045b5f742890c689 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update contact information in license headers.Jason McDonald2012-01-231-1/+1
| | | | | | | Replace Nokia contact email address with Qt Project website. Change-Id: I431bbbf76d7c27d8b502f87947675c116994c415 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Reimplement QVariant to QDebug streaming.Jędrzej Nowacki2012-01-101-0/+51
| | | | | | | New implementation fixes some commented code marked as FIXME. Change-Id: If8f5bebedd65bcf8f839d804c2022ca79ef82ddf Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Update copyright year in license headers.Jason McDonald2012-01-051-1/+1
| | | | | Change-Id: I02f2c620296fcd91d4967d58767ea33fc4e1e7dc Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Refactor QVariant handlers.Jędrzej Nowacki2012-01-041-43/+11
| | | | | | | | | | | | | | | | | | | | | | | | | QVariant implementation is based on delegation to a handler. The handler has rather simple construction, it is a set of function that implements a switch statement over known types and redirects calls to a right method of an encapsulated types instance. Unfortunately after qt modularization project, it is not easy to use types directly from different modules, as they can be undefined or completely unaccessible. Which means that each module has to implement own handler to cooperate correctly with QVariant. We can suspect that list of modules known to QVariant will grow and it is not limited to GUI, Widgets and Core, therefore it would be nice to have an unified, from performance and source code point of view, way of working with handlers. This patch is an attempt to cleanup handlers. Keynotes: - Each handler is working only on types defined in the same module - Core handler implements handling of primitive types too - Custom types have an own handler - Each handler is independent which means that dispatch between handlers is done on QVariant level - Handlers might be registered / unregistered using same interface Change-Id: Ib096df65e2c4ce464bc7a684aade5af7d1264c24 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Fixed static assert in qvariant template magicDenis Dzyubenko2012-01-041-1/+1
| | | | | | | | | CallConstructor<T, /* CanUseInternalSpace = */ false> is called when we need to construct an object that couldn't be fit in qvariantdata, meaning either it is not a POD type (Q_PRIMITIVE_TYPE), or it is simply too large to fit there. Change-Id: Ied122b4a6f600e14312a8d515f5b3e91214a94f1 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
* Fix movablity of QVariant.Jędrzej Nowacki2011-12-221-24/+35
| | | | | | | | | | | | | | | | After 8fd64d22ac7892b061a09c42c72aacf033b80876 (Make usage of internal QVariant space.) change QVariant started to "inherit" movablity from interned type. This change fix it by interning only movable type in QVariant and by using external allocation for not movable ones. Obviously, this change has negative impact on QVariant it self, but after it, QVariant will behave a lot nicer with our containers. Change-Id: Ibffc95833918f65be737f52d694ee81a2036c412 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QVariant: Fix MSVC compiler warning about unused variable null.Friedemann Kleint2011-11-091-2/+1
| | | | | | | | | Use static method isnull(). Introduced by ca26fefc0624264262a2abe630568271cefa2753. Change-Id: I752f8d8a5ec473dcc5f50fbda47d061b8d3a7e13 Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
* [optimization] QVariants comparisonJędrzej Nowacki2011-11-091-2/+2
| | | | | | | | | | | QMetaType::isRegistered and QMetaType::typeName are quite expensive. To compare two custom objects we need to have their type name (for dereferenced comparison). If the name exist we know for sure that the type is registered and we do not have to call QMetaType::isRegistered anymore. Change-Id: Iba631e012504c8633868a902880fa30d38afb917 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Make usage of internal QVariant space.Jędrzej Nowacki2011-11-091-0/+292
| | | | | | | | | | | | | | | | | | | | | | Each QVariant instance has internal storage which may be used for well-know basic types. This patch changes the behavior by delegating type dependent operation to QMetaType class which knows more types than QVariant itself. The patch significantly reduce amount of code in QVariant implementation. There are few side effects of this patch: - better performance: * for Core types when using Gui (QGuiVariant is able to construct Core types) * for small custom types (QVariant::Private::Data is used for all types that has size small enough) - comparing two QVariants can give different result for small custom types (binary comparison instead of pointer comparison) Change-Id: Ic17fa500d6a882110bfba896fd456c8e6c7a63a9 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Update licenseheader text in source files for qtbase Qt moduleJyri Tahtela2011-05-241-17/+17
| | | | | | | Updated version of LGPL and FDL licenseheaders. Apply release phase licenseheaders for all source files. Reviewed-by: Trust Me
* Initial import from the monolithic Qt.Qt by Nokia2011-04-271-0/+153
This is the beginning of revision history for this module. If you want to look at revision history older than this, please refer to the Qt Git wiki for how to use Git history grafting. At the time of writing, this wiki is located here: http://qt.gitorious.org/qt/pages/GitIntroductionWithQt If you have already performed the grafting and you don't see any history beyond this commit, try running "git log" with the "--follow" argument. Branched from the monolithic repo, Qt master branch, at commit 896db169ea224deb96c59ce8af800d019de63f12