summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qmetatype.h
Commit message (Collapse)AuthorAgeFilesLines
* QMetaType: Fix compilation with non default constructible Q_GADGETOlivier Goffart2015-05-271-1/+1
| | | | | | | | | | | Do not try to automatically register the meta type for Q_GADGET that are not default constructible. This fixes a source incompatibility in the function pointer syntax of QObject::connect when such types are used as an argument of a signal. Task-number: QTBUG-45721 Change-Id: I3065f6d57bc1f37e16988d2dee99118de250ca56 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QMetaType: Do not automatically register types that derives from a Q_GADGETOlivier Goffart2015-05-231-4/+8
| | | | | | | Otherwise the type is registered with the wrong name Change-Id: I68ec3a05e2528816626e648b46ccc9d70b004866 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Fix QtPrivate::IsQEnumHelper<void>Olivier Goffart2015-05-171-0/+1
| | | | | Change-Id: I1633ef128212a6b99b66129f13e0b4d5ea46644d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add support for unregistering of custom meta types.Robert Griebl2015-04-141-0/+1
| | | | | | | | | | | | | This patch addresses a specific Qml problem, where the meta types list will grow indefinitely when unloading and reloading Qml components over and over (in an failed effort to save memory). The implementation is not specific to Qml though, but will cater to all use-cases where registered types may not live until the application's termination. Change-Id: Ic0224dcd19aeb559715ef088b22a30509be2456b Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Silence clang warnings in C++03 modeOlivier Goffart2015-04-011-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | C++03 forbid the use of local or unnamed type as template parameter. But in C++11 that is allowed, and clang accept them even in C++03 mode, but with a warning. The Warning happen for example with this code: enum { Foo = 3 }; int x = 3 << Foo; Then the compiler issues warnings: metatype.h:1379:31: warning: template argument uses local type [-Wlocal-type-template-args] enum { Value = sizeof(qt_getEnumMetaObject(declval())) == sizeof(QMetaObject*) }; ^~~~~~~~~~~~~~~~~~~~ qdebug.h:269:42: note: in instantiation of template class 'QtPrivate::IsQEnumHelper<(anonymous enum)>' requested here typename QtPrivate::QEnableIf<QtPrivate::IsQEnumHelper<T>::Value, QDebug>::Type operator<<(QDebug dbg, T value) Normaly the compiler should not even try to instantiate the operator<< with such types in C++03 mode. Change-Id: I48c7d5d1836fd87986835fe15c7e0b1beb73c728 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix source incompatibility while connecting signals with forward declared ↵Olivier Goffart2015-03-181-4/+4
| | | | | | | | | | | | | | | | | | | arguments QObject::connect tries to determine if the arguments are registered metatypes. This used to work even for arguments that were forward declared. But now, the metatype system tries to call QtPrivate::IsQEnumHelper<T>::Value to know if it is registered. That fails on gcc if T is forward declared. Apparently gcc needs to know the full type of T to pass it in the ellipsis function, even within a sizeof expression. So change the ellipsis expression to a template one. Task-number: QTBUG-44496 Change-Id: I7fa07bd3cde470b134c2ec53b0d581333d16a6f1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make QPersistentModelIndex an internal meta-typeGabriel de Dietrich2015-03-061-2/+3
| | | | | | | | | | | It was already a user meta-type, so it only gets promoted to internal. [ChangeLog][QtCore] QPersistentModel index becomes an built-in meta-type, including QVariant support. Change-Id: I63d733d1eb66aa61691e7afce27fe7372a83ac00 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* QMetaType: improve docs and commentsOlivier Goffart2015-02-141-0/+3
| | | | | Change-Id: I7bcc8cec95eb5abda75d936732b1113b943622dc Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* QMetaType: Automatic registration of Q_GADGET and Q_ENUM typesOlivier Goffart2015-02-121-2/+53
| | | | | | Change-Id: If43dcc2b77fea5ae3ec40cc847467fc21fbd2c83 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.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>
* QMetatype: Register the QMetaObject of a Q_ENUM or Q_FLAGOlivier Goffart2015-02-051-1/+19
| | | | | Change-Id: Id1343c3fb51d88a43d4d97e8859dbe2b0cfbea34 Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
* Support QMetaType::equals()Alex Blasche2015-01-131-0/+29
| | | | | | | | This avoids having to define operator< for types where operator== is required but operator< doesn't make any sense (e.g. QGeoCoordinate). Change-Id: I81f6a9d8fc0009a4514c974b5e02b446c50d1e31 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove qRegisterSequentialContainer, qRegisterAssociativeContainer tracesKai Koehne2015-01-071-5/+2
| | | | | | | | | | | The methods where introduced with commit 01fb843af88d9, but removed before the next release in a1898f446651. Also add a comment that we should get rid of the special Q_CC_MSVC handling in Qt 6. Change-Id: I8bb992a59f31a0de7e3f14f34d1d4f604ebfe8f3 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Merge remote-tracking branch 'origin/5.4' into devFrederik Gladhorn2014-12-291-1/+1
|\ | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/tools/qbytearray.cpp src/gui/kernel/qplatformsystemtrayicon.cpp src/gui/kernel/qplatformsystemtrayicon.h src/plugins/platforms/xcb/xcb-plugin.pro Change-Id: I00355d3908b678af8a61c38f9e814a63df808c79
| * MSVC: Restore 'public' accessibility of QMetaType member functionsAndy Shaw2014-12-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | They were made 'private' as a side effect of a change enabling support of template friends for MSVC. However, accessibility is part of the MSVC's name mangling and thus BC was broken. [ChangeLog][Important Behavior Changes] Restored binary compatibility with Qt 5.3.2 on Windows when using MSVC 2012 or MSVC 2013. This means that Qt 5.4.1 is no longer binary compatible with Qt 5.4.0 when using either of those compilers. Change-Id: I18679aa15821a7365606dc80fdc8411641573820 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Implement proper C++ type numeric promotion for QVariant comparisonsThiago Macieira2014-12-031-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, QVariant would try to convert one operand to the other's type, which would produce unexpected results: the results would depend in the order of the operands and whether there was data loss in the conversion. In addition, ordering comparisons were only done with signed values, yielding other unexpected results, like QVariant(LLONG_MAX / 2) < QVariant(Q_UINT64_C(0)). Instead, try to obey the C++ standard rules for type promotion in expressions. Our code is a little simpler than the standard would seem to require since we know some more details from the ABI. [ChangeLog][Important Behavior Changes][QVariant] QVariant now obeys the C++ type promotion rules when comparing numeric types (integrals, float and double), including the fact that unsigned comparisons are preferred for types of the same rank (that is, now QVariant(-1) > QVariant(0U)). Task-number: QTBUG-42722 Change-Id: Ie7b19073dcb45485354710975e561bcdb1a753f1 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
* | Remove unused private apiJędrzej Nowacki2014-11-191-14/+0
| | | | | | | | | | Change-Id: Iffe5a33b8a1f134d722371a9e92ba9c9d13c51f8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Reduce code bloat, by cleaning up QMetaTypeFunctionHelperJędrzej Nowacki2014-11-171-12/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Create and Delete wrappers are not necessary, because they can be easily simulated with Construct and Destruct. This change removes redundant function wrappers and a bit of over-optimized code. Gain is quite big: Before: text data bss dec hex filename 5366008 47460 14904 5428372 52d494 libQt5Core.so.5.5.0 505578 7060 2124 514762 7daca libQt5DBus.so.5.5.0 5591079 134656 6728 5732463 57786f libQt5Gui.so.5.5.0 1398785 31676 2576 1433037 15ddcd libQt5Network.so.5.5.0 6642431 220952 2536 6865919 68c3ff libQt5Widgets.so.5.5.0 After: text data bss dec hex filename 5342559 47460 14904 5404923 5278fb libQt5Core.so.5.5.0 496025 7068 2124 505217 7b581 libQt5DBus.so.5.5.0 5579291 134272 6728 5720291 5748e3 libQt5Gui.so.5.5.0 1389461 31676 2576 1423713 15b961 libQt5Network.so.5.5.0 6637139 220952 2536 6860627 68af53 libQt5Widgets.so.5.5.0 Cost of the change, is moved to CPU while calling QMetaType create() and destroy(), these two functions became a bit slower. The cost should not be visible, because they call operator new anyway. Change-Id: I34fd410343377d9c29925675d7da8172bfda9ce6 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Let QMetaType know which types are Q_GADGETOlivier Goffart2014-11-161-3/+19
| | | | | | | | | | | | | | | | | | This is required so we can take a QVariant and detect that it contains a Q_GADGET and then use method like QMetaType::metaObject and QMetaProperty::write with the QVariant::data Change-Id: I3603692e4e84426e10bf59949e3def3ea4947bec Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Add QMetaType::type(QByteArray) functionKent Hansen2014-10-311-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QMetaType::type(const char *) requires that the string argument is 0-terminated. This new overload makes it possible to query the type of a string with an explicit length. In particular, QByteArrays constructed by QByteArray::fromRawData(), for example from a substring of a normalized method signature (the "int" part of "mySlot(int"), can now be queried without making a copy of the string. Also, Qt5 meta-objects represent type names as QByteArray literals, which can be fed directly to this new QMetaType::type() overload (no need to call strlen). Change-Id: I60d35aa6bdc0f77e0997f98b0e30e12fd3d5e100 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/5.4' into devFrederik Gladhorn2014-10-271-0/+15
|\| | | | | | | | | | | | | Conflicts: src/gui/text/qfontdatabase.cpp Change-Id: I6ac1f55faa22b8e7b591386fb67f0333d0ea443d
| * Fix QVariant associative container conversion from built-in types.Jędrzej Nowacki2014-10-241-0/+15
| | | | | | | | | | | | Task-number: QTBUG-41403 Change-Id: I9dab0f9450cac11678eb6d20abd2dd08e86e0900 Reviewed-by: Stephen Kelly <steveire@gmail.com>
* | Merge remote-tracking branch 'origin/5.4' into devOswald Buddenhagen2014-09-291-19/+11
|\| | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/tools/qbytearray.cpp src/gui/image/qimage.cpp src/gui/image/qppmhandler.cpp src/gui/kernel/qguiapplication.cpp src/gui/painting/qpaintengine_raster.cpp Change-Id: I7c1a8e7ebdfd7f7ae767fdb932823498a7660765
| * 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>
* | Merge remote-tracking branch 'origin/5.4' into devFrederik Gladhorn2014-09-011-2/+5
|\| | | | | | | Change-Id: I2811ff0b9d4097f0be60ff16e9664a5060cff23e
| * Mark QByteArrayList as metatype built-in type.Jędrzej Nowacki2014-08-281-2/+5
| | | | | | | | | | | | | | As a side effects it also adds core templates types to the tests Change-Id: I0e3338e0bffdf21982aa83d404c83288e54411f4 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* | QMetaType: disallow automatic registration of reference typeOlivier Goffart2014-08-131-0/+3
|/ | | | | | | | | | | | | | The automatic registration code that would be added will break with a reference type. QObject's template code calls QMetaTypeId2 on the arguments of the signal. Including on references. Reference type cannot be register as metatype. They are not supported in QVariant, or in QueuedConnection. Change-Id: I83f2e50f9f886909dc24f3809c990e5763012cc2 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* Make VectorBoolElements static properties const.Jędrzej Nowacki2014-06-251-2/+2
| | | | | | | The elements should not be changeable. Change-Id: I108cb42b1237cd61c4d8f2fbe13305fbbf4ef311 Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
* Metatype: Specialize IteratorOwner for vector<bool>Stephen Kelly2014-06-161-3/+30
| | | | | Change-Id: I542af3a77b0a139e137a5a736b74042a8c25eb95 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2014-05-131-0/+1
|\ | | | | | | | | | | | | Manually changed enum to LibGL in src/plugins/platforms/xcb/qglxintegration.cpp Change-Id: If34ee6cce3d1d51fb4bb1fdfa59c30389ea0d207
| * Add a comment about not obvious code in VariantData.Jędrzej Nowacki2014-05-021-0/+1
| | | | | | | | | | Change-Id: I943af28c47b396aa35173da2a1294b86c8a522fa Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Build fix for auto-registration of Container<void*>Jędrzej Nowacki2014-04-231-2/+9
| | | | | | | | | | | | | | | | IteratorOwner pointer specialization was failing for void* because of an invalid function overload. Change-Id: I80355ddd2b871c1fa2fa5bf5a4ed8bc7768fc3c9 Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
* | QMetaType: Specialize IsPointerToTypeDerivedFromQObject for const void*Stephen Kelly2014-04-221-0/+5
| | | | | | | | | | | | | | | | | | 'const void' is not derived from QObject, and is not a type we can use sizeof to determine that. Change-Id: I008f444bbed9fc8f9147da0f7f336757f660e224 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* | Merge remote-tracking branch 'origin/stable' into devIikka Eklund2014-04-011-35/+7
|\| | | | | | | Change-Id: I2a6eb9dd7724931bc89f28bcc156e77c4e26d069
| * Reduce clang compilation time of tst_qmetatype by ~2%Jędrzej Nowacki2014-03-281-35/+7
| | | | | | | | | | Change-Id: I64fe12dd0bf9c35ae06fc5a68addc36848cdda3b Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
* | Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2014-03-241-1/+6
|\| | | | | | | | | | | | | Conflicts: src/gui/image/qjpeghandler.cpp Change-Id: I9db3acea7d5c82f5da679c8eaeb29431136665f0
| * Fix Q_DECLARE_METATYPE macroJędrzej Nowacki2014-03-171-1/+2
| | | | | | | | | | | | | | | | | | The macro should stringify value of the given token not the token itself. Task-number: QTBUG-37547 Change-Id: I90f4fa613bd13d5a581828ab13f620b40dfd3593 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
| * Remove level 4 compiler warnings from MSVC.David Schulz2014-03-151-0/+4
| | | | | | | | | | | | | | | | | | | | Task-number: QTBUG-7233 Change-Id: I52067e3a22e98a62fd87415906e54a54ff2d6b49 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com> Reviewed-by: Oliver Wolff <oliver.wolff@digia.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com> Reviewed-by: Dave McClelland
* | QtCore: Fix MSVC 64bit warnings about conversion from size_t to int.Friedemann Kleint2014-02-251-2/+2
|/ | | | | | | warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data Change-Id: I9be380cbb7bed4cd95515074c7cad7e41a511dc9 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* Fix ‘looses precision’ warning in public APIKurt Pattyn2013-12-271-3/+3
| | | | | Change-Id: I935e6f278e539f8e6aaca0bc381371ec85aa5c67 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* QMetaType: Fix equality comparison of type-erased iterators.Stephen Kelly2013-12-131-2/+12
| | | | | | | Task-number: QTBUG-33997 Change-Id: I0d4da562540df0e3732769881ba124cb980f6b82 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* QMetaType: Fix copy of type erased iteratorStephen Kelly2013-12-131-2/+10
| | | | | | | | | | | Behavior differs depending on whether the iterator is a value_type*, or a different class entirely. Ensure that the correct behavior is used when copying. Task-number: QTBUG-33997 Change-Id: Ib6db2a3c4a5aa861b851833a7f0ecb855a3e828f Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* QMetaType: Rename template type of type-erased iterator operations.Stephen Kelly2013-12-121-6/+6
| | | | | | | | This struct is a specialization for the case that the const_iterator is a pointer to the value type. Reflect that in the type name. Change-Id: I0a4ac03840658056285080860baec8313746c71c Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Correct compiler warnings for sign conversionKurt Pattyn2013-12-061-3/+3
| | | | | | | | | | | | | qstrlen() returns a uint. When assigned to an int, the compiler warns about sign conversions. Because these calls are used within templates, the code appears in user generated code, and hence the warnings cannot be suppressed by the -isystem directive. Using the -Werror flag, makes the user code fail. [ChangeLog][QtCore] Fixed sign conversion warnings in code using QMetaTypeId. Change-Id: Ib7603679d6526467f8cbb9d7bcf5f56c6af47ceb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* MetaType: Fix operator{+,-}(int) with the type-erased const_iterators.Stephen Kelly2013-09-131-0/+28
| | | | | | | | Make sure we don't modify the lhs. Instead copy it and advance the copy. Change-Id: I3440e8e175bfc299f8f83b816faca54fa3f79e43 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Remove some unneeded constructors.Stephen Kelly2013-09-131-11/+3
| | | | | Change-Id: I34f86960dc0cfaada509957bca5466b2765e8239 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Fix new warnings under Clang 3.3Thiago Macieira2013-09-131-34/+36
| | | | | | | | | | | | | | | Probably added by a1898f4466518bf3e1b6e9154eec05ecf9d909e3. qmetatype.h:70:29: error: inline function 'qMetaTypeId<QtMetaTypePrivate::QSequentialIterableImpl>' is not defined [-Werror,-Wundefined-inline] qmetatype.h:1363:30: note: used here const int toId = qMetaTypeId<QtMetaTypePrivate::QSequentialIterableImpl>(); qmetatype.h:70:29: error: inline function 'qMetaTypeId<QtMetaTypePrivate::QAssociativeIterableImpl>' is not defined [-Werror,-Wundefined-inline] qmetatype.h:1386:30: note: used here const int toId = qMetaTypeId<QtMetaTypePrivate::QAssociativeIterableImpl>(); Change-Id: I9afe1a3d50ab23eb701797e28b259966dc95a147 Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
* Add a convenient way to get a type-erased smart pointer from a QVariant.Stephen Kelly2013-09-111-0/+45
| | | | | | | | | | | | Any known smart pointer in a QVariant can be handled in this way. The metatype system can be informed of new smart pointer types using an existing macro which is now documented. This is very similar to the existing infrastructure for containers. Change-Id: Iac4f9fabbc5a0626c04e1185d51d720b8b54603d Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Metatype: Remove the need for runtime-registration of 3rd party containers.Stephen Kelly2013-09-091-69/+33
| | | | | | | | | Replace that need with a macro so that registration of the container helper conversions is done at the time of registration of the container (usually when it is put into a QVariant). Change-Id: I823fb3fdbce306ebc9f146675ac43724cec678d5 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Move the preprocessor iterator for Qt smart pointers with the others.Stephen Kelly2013-09-061-8/+10
| | | | | | | Use it to forward declare the types. Change-Id: I48d9e32dcf02471d197a82502d96d60807d11d57 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>