summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qmetatype.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Support QMetaType::equals()Alex Blasche2015-01-131-3/+32
| | | | | | | | 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>
* Reduce code bloat, by cleaning up QMetaTypeFunctionHelperJędrzej Nowacki2014-11-171-137/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-4/+18
| | | | | | | | | 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>
* Fix QMetaType::metaObjectForType for QtGui and QtWidgets typesOlivier Goffart2014-11-031-1/+20
| | | | | | | | | | | | Follow the same convention as other functions using the QMetaTypeSwitcher It was not a problem since none of the built-ins type in QtWidgets or QtGui were pointer and could not have a QMetaObject. But since we want to register the metaobject for Q_GADGET, it would fail compilation as types like QFont are not defined in QtCore. Change-Id: I6307bf6f25439ed48355ef7ecfa60575de318a25 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Add QMetaType::type(QByteArray) functionKent Hansen2014-10-311-6/+19
| | | | | | | | | | | | | | | | | | | 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>
* 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>
* Fix typo in QMetaType documentation.Mitch Curtis2014-09-091-1/+1
| | | | | Change-Id: I934b68978fb32a518ed7cf9b47f1600982f58f66 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* Mark QByteArrayList as metatype built-in type.Jędrzej Nowacki2014-08-281-0/+8
| | | | | | | 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>
* Add missing #include <qdatastream.h> or <qiodevice.h>Thiago Macieira2014-08-071-0/+1
| | | | | | | Lots of code depended on an indirect includes from qstringlist.h. Change-Id: I33d0dce33d64302d6c0e49180cc1249b90ab27c5 Reviewed-by: Marc Mutz <marc.mutz@kdab.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-0/+5
| | | | | Change-Id: I542af3a77b0a139e137a5a736b74042a8c25eb95 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* Doc: Adding mark-up to boolean default values.Jerome Pasion2013-10-081-24/+24
| | | | | | | | | | | | | | | | | Default values should have mark-up to denote that they are code. This commit changes: -"property is true" to "property is \c true". -"Returns true" to "Returns \c true". -"property is false" to "property is \c false". -"returns true" to "returns \c true". -"returns false" to "returns \c false". src/3rdparty and non-documentation instances were ignored. Task-number: QTBUG-33360 Change-Id: Ie87eaa57af947caa1230602b61c5c46292a4cf4e Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
* Fix some doc errors.Frederik Gladhorn2013-09-211-4/+4
| | | | | | | Change-Id: Ib874d7e9671d9cee75fe41f4dac5d0de7b09245e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Topi Reiniö <topi.reinio@digia.com> Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
* Add a convenient way to get a type-erased smart pointer from a QVariant.Stephen Kelly2013-09-111-0/+16
| | | | | | | | | | | | 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-31/+34
| | | | | | | | | 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>
* QVariant: Don't crash when doing user-defined conversion to QObject*Stephen Kelly2013-09-051-0/+2
| | | | | | | | | The destructor of the ConverterFunctor calls unregisterConverter. If the instance is static (as it is in qmetatype.h), then this method can be called after the QGlobalStatic has already been destroyed. Change-Id: I33b70734cbe09dfa888e887280c349e43ad1b855 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Make the qfatal for redeclaring a type with the same name a warning.Richard J. Moore2013-06-251-5/+5
| | | | | | Change-Id: I5a25b2043a6b5a598a004d30c9a8056564c136e3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2013-06-121-0/+1
|\ | | | | | | | | | | | | Conflicts: src/plugins/platforms/cocoa/qcocoamenubar.mm Change-Id: I4a699fc8a7f30b2af9de8e496c3d5f027b7495bb
| * Mark the Q_DECLARE_OPAQUE_POINTER macro as introduced in 5.0Laszlo Papp2013-06-121-0/+1
| | | | | | | | | | Change-Id: Ida52c9f1f72b628d9a7faaf7998798e781b53df2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Core: QDebug and comparison operator support metatypes.Christoph Schleifenbaum2013-05-271-16/+124
| | | | | | | | | | | | | | | | 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>
* | Add container access functionality for associative containers in QVariant.Stephen Kelly2013-05-201-0/+15
| | | | | | | | | | Change-Id: I4763a4c157e52918a0a68cba63624c0649aca235 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* | Change the ownership semantics of metatype converter functions.Stephen Kelly2013-05-201-9/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Destroying the instances is a problem because the instances might have been created in a plugin. In that case, the destructor of the instance will be implemented in the plugin. As the instance destruction code is run very late, the plugin might have already been unloaded by the time an attempt is made to destroy the instance. The workaround is to create static instances on the stack. Task-number: QTBUG-31142 Change-Id: Ic2632c3548a734b742da46d90249916c35705d46 Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* | Fix since version of new metatype conversion functions.Stephen Kelly2013-05-081-8/+8
| | | | | | | | | | Change-Id: Icedd0942eaef9bdcf034d747f0a03a00ca461a95 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* | Add automatic container access registration for built-in containers.Stephen Kelly2013-05-081-0/+4
| | | | | | | | | | Change-Id: I4d590c23e072994930922ff73367600f848fbcf0 Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
* | Add QVariant container iteration API.Stephen Kelly2013-05-081-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Core: Support for converting user defined QVariant types.Christoph Schleifenbaum2013-05-081-0/+122
|/ | | | | | | | | | | | | | | | | 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>
* Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2013-01-221-1/+1
|\ | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qsavefile_p.h src/corelib/tools/qregularexpression.cpp src/gui/util/qvalidator.cpp src/gui/util/qvalidator.h Change-Id: I58fdf0358bd86e2fad5d9ad0556f3d3f1f535825
| * Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | | | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2013-01-161-5/+31
|\| | | | | | | | | | | | | Conflicts: src/widgets/styles/qstyleanimation.cpp Change-Id: Iae570895be6544de80f9c1ec309d1a08c59daff8
| * Ignore WasDeclaredAsMetaType flag during binary check.Jędrzej Nowacki2013-01-101-5/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Nobody should break ODR, but we were living with apps breaking it for at least 8 years. Sure it is an undefined behavior but in many cases it works. I do not think that Qt should enforce usage of a proper C++, it is role of a tool chain. Qt can only indicate that something is going terribly wrong. Make message a bit more verbose. Sometimes the ODR violation is not that easy to fix, therefore a hint is a nice addition. Update documentation of qRegisterMetaType. Change-Id: I61dcccc840eec80a4ed5b8a212a912807d239d8c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge "Merge branch 'stable' into dev" into refs/staging/devJędrzej Nowacki2013-01-071-0/+1
|\|
| * Declare the QMetaType::WasDeclaredAsMetaType enum as privateThiago Macieira2013-01-031-0/+1
| | | | | | | | | | | | | | | | Omit its value in the documentation. Change-Id: I474faefde23b0e2e0a77a9e6391fd556a6523128 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com> Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
* | Rename QRegularExpression-related feature defs to QT_NO_REGULAREXPRESSIONGiuseppe D'Angelo2013-01-071-4/+4
|/ | | | | | | | | | | | QRegExp and QRegularExpression are totally independent, therefore using two different defines is the right thing to do. Also, document the new define in qfeatures.{txt,h}. Change-Id: Ice4826ea543f4b22f1cc27bf31ed6e043d0c43b0 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* QMetaType build fix with Q_NO_CURSOR and friends.Jędrzej Nowacki2012-09-271-5/+7
| | | | | | | | | | | | QMetaType has a way to "switch off" some types from the build. QtMetaTypePrivate::TypeDefinition<T>::IsAvailable is defined as false for all unaccessible types. Sadly that information was never used by gui and widget handlers. The patch implements it. Change-Id: Ie5835be4c88cfbbca8a4e9199e31ddfc20cae190 Reviewed-by: J-P Nurmi <jpnurmi@digia.com> Reviewed-by: Jing Bai <jing.bai@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.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>
* Improve QMetaType docs.Jędrzej Nowacki2012-09-131-10/+214
| | | | | | | Change-Id: I4ad4188d1bb984b83ffe4bb4ff098158e888d183 Reviewed-by: Qt Doc Bot <qt_docbot@qt-project.org> Reviewed-by: Mitch Curtis <mitch.curtis@nokia.com> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@nokia.com>
* Change SChar to metatype id 40.Stephen Kelly2012-09-031-1/+1
| | | | | | | | | This fills the gap left by QWidgetStar, making the sequence between FirstCoreType and LastCoreType contiguous, which some benchmarks assume to be true anyway. Change-Id: I2d5d202b6246a9065fdf77f325a4a04279dbe4b7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: Add \inmodule QtCore to all QtCore class doc bodiesThiago Macieira2012-08-231-0/+1
| | | | | Change-Id: I19100755c97cc155c76a859e19940e9f9222d34e Reviewed-by: Casper van Donderen <casper.vandonderen@nokia.com>
* Remove QWidgetStar.Stephen Kelly2012-08-181-4/+1
| | | | | | | | | | | | This allows us to remove the odd hacks to get the static metaobject for the QWidget* metatype. The QWidget* is still an automatic metatype thanks to the QObject partial template specialization. It is registered as a metatype at runtime automatically in qwidgetsvariant.cpp. Change-Id: Ie01b69eadf2cbe87af1a86c3284550f60dcf9e94 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Make the "\internal" qdoc command stand on its own lineLaszlo Papp2012-08-151-9/+18
| | | | | | | | | | The qdoc manual currently claims that the command must stand on its own line. The change follows the consistency with the rest and how the example looks like inside the qdoc manual for this command. Change-Id: I6b653dc95cf9d84e4adf32220dace5d313678419 Reviewed-by: Casper van Donderen <casper.vandonderen@nokia.com>
* Remove Q_UNUSED for the metaObject.Stephen Kelly2012-07-191-2/+0
| | | | | | | | | The object is no longer unused. Change-Id: Ia82539220855321f2986c5791b70be5df399baca Reviewed-by: Laszlo Papp <lpapp@kde.org> Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
* fix "No such ..." doc error for QMetaType::typeName()Jeremy Katz2012-07-191-1/+1
| | | | | Change-Id: If00c728ec793a65f62d76d8301c7f6658e7af8a0 Reviewed-by: Casper van Donderen <casper.vandonderen@nokia.com>
* Store the QMetaObject with the QMetaType.Stephen Kelly2012-07-011-1/+64
| | | | | | | | This will allow conversion between pointers to compatible QObject derived types. Change-Id: I19e08934571fb3f1b91e594892214041fe5f6a11 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
* Move QIcon metatype handlers back to QtGuiOlivier Goffart2012-05-181-2/+2
| | | | | | | | | | | QIcon has been moved back from QWidget to QtGui, so the QIcon QVariant and QMetaType handler can now be moved back to QtGui. Also we can give back QIcon its old number, allowing to get rid of some compatibility hack when unstreaming QVariant Change-Id: I439d5c2987c06ecd619f394407850f678164afb8 Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
* Use bool for the template argument.Stephen Kelly2012-05-091-1/+1
| | | | | | | | It is only ever called with 'true' or 'false'. Change-Id: Ibaba1c964cebb3ac75a230471a7a6547c2245039 Reviewed-by: Kent Hansen <kent.hansen@nokia.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
* Introduce a new built-in type: signed char.Jędrzej Nowacki2012-05-081-0/+7
| | | | | | | | | | | | C++ distinguish between "char", "signed char" and "unsigned char", they are three independent types. Fix QVariant behavior on ARM. On ARM "char" may mean "unsigned char", but we depends on the sign during a numerical conversions. Change-Id: I610ce3fb88ed5964b67f3ae442d264fe16b2d261 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/api_changes'Lars Knoll2012-05-031-17/+16
|\ | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/global/qglobal.cpp src/corelib/global/qlogging.cpp src/gui/kernel/qguiapplication.h src/gui/kernel/qwindow.cpp src/gui/kernel/qwindow.h tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp Change-Id: I62a8805577a7940d4d36bed985eb3e7019d22f2e
| * Remove redundant check in QMetaType::typeInfoJędrzej Nowacki2012-04-181-2/+1
| | | | | | | | | | | | | | The check was introduced when void was not a fully defined type. Change-Id: I4df8607999436f8db92be77fc8fd203fc66c2816 Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
| * Hide QTypeModuleInfo in a private namespace.Jędrzej Nowacki2012-04-181-15/+15
| | | | | | | | | | | | | | The class is private and shouldn't pollute global namespace. Change-Id: Ib44473fd72e5a70096eeff1662e88b29263d19c6 Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
* | Fix regression in connectNotify(const char *) emissionKent Hansen2012-05-011-8/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reimplementations of connectNotify() and disconnectNotify() can assume that the signal argument is in normalized form, but after the introduction of the Qt5 meta-object format, it could happen that it's not. The problem is that the internal QArgumentType class, which attempts to resolve a typename to a type id, was calling QMetaType::type(). QMetaType::type() falls back to trying the normalized form of the typename if the original argument can't be resolved as a type (this behavior isn't documented, but that's how it works). This means that e.g. QMetaType::type("const QString &") returns QMetaType::QString. Since QMetaObjectPrivate::indexOfMethodRelative() (more specifically, the methodMatch() helper function) prefers to compare type ids over typenames (since the type ids are stored directly in the meta- object data for built-in types), the method lookup would *succeed* for signatures with non-normalized built-in typenames as parameters. QObject::connect() would then think that it did not have to normalize the signature (see "// check for normalized signatures"). The consequence was that the original, non-normalized form got passed to connectNotify(). This commit introduces an internal typename-to-type function that is the same as QMetaType::type(), except it doesn't try to normalize the name. This way, the only place where normalization can occur in the signature-to-meta-method processing is through the calls to QMetaObject::normalizedSignature() in QObject::connect() itself. The implication is that there are now cases where the method signature will be decoded and processed twice, where processing it once was sufficient before. On the other hand, it is consistent with the pre-Qt5-meta-object behavior, where we predict that the signature is already normalized, and only perform (comparatively costly) normalization if the initial lookup fails. Change-Id: Ie6b60f60b0f9a57ebd378d980329dac62d57bbd9 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>