summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qmetatype.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Apply Q_CONSTINIT across the codebaseMarc Mutz2022-03-291-2/+2
| | | | | | | | | Still not complete. Just grepping for static and thread_local. Task-number: QTBUG-100486 Change-Id: I90ca14e8db3a95590ecde5f89924cf6fcc9755a3 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QtCore: Replace remaining uses of QLatin1String with QLatin1StringViewSona Kurazyan2022-03-261-1/+1
| | | | | | | Task-number: QTBUG-98434 Change-Id: Ib7c5fc0aaca6ef33b93c7486e99502c555bf20bc Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Doc: Add \relates command for documented global functions/macrosTopi Reinio2022-03-251-1/+1
| | | | | | | | | | | | | Global functions need an associated header file/class/namespace to make the documentation visible. Remove QDoc comment tag (/*!) for an internal function. Pick-to: 6.3 Task-number: QTBUG-99578 Change-Id: Id390d433d7e081fc90fa57a02097b6c37fa13bee Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* QMetaType: remove an unused static pointer variableMarc Mutz2022-03-181-2/+1
| | | | | | | | | | | | | Unlike the Gui and Widgets pointers, the Core one wasn't needed, because the only user can inline the variables contents. Saves one relocation. Pick-to: 6.3 Change-Id: Ib7535e1a29c5125eea55c66dad6d2d1de72f6bc1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Core: Do not depend on transitive includesFabian Kosmale2022-03-171-0/+2
| | | | | Change-Id: I2c71188a4d27692a2d6ef1aa447b329627214b17 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* qmetatype: Remove left-over module association codeFabian Kosmale2022-02-091-6/+0
| | | | | | | | | Qt 6's metatype does no longer care whether the type is from Core, GUI or a user metatype. Change-Id: I4f41d44a61a9839f58b957219c2404512630587a Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Prevent repeated instantiations of some qRegisterNormalizedMetaType<>s [1/N] ↵Marc Mutz2022-01-211-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (QtGui) Create macros that wrap the magic developed in 7d63efc16f65f98c657caa90e0d7e9b72a879ade and apply it to all Q_DECLARE_METATYPE invocations that show up in Clang -ftime-trace for a PCH'ed QtGui build. Effects on compile times: Clang 10 -ftme-trace: $ ClangBuildAnalyzer --analyze qtgui-before.trace | head -n6 Analyzing build trace from 'qtgui-before.trace'... **** Time summary: Compilation (523 times): Parsing (frontend): 628.3 s Codegen & opts (backend): 304.5 s $ ClangBuildAnalyzer --analyze qtgui-after.trace | head -n6 Analyzing build trace from 'qtgui-after.trace'... **** Time summary: Compilation (523 times): Parsing (frontend): 546.0 s Codegen & opts (backend): 304.4 s GCC 11 time (bash builtin): before: $ time for ((i=0; i < 3; ++i)) do touch src/gui/painting/qpolygon.h ; ninja libQt6Gui.so; done real 4m13,539s user 49m24,416s sys 3m18,177s after: $ time for ((i=0; i < 3; ++i)) do touch src/gui/painting/qpolygon.h ; ninja libQt6Gui.so; done real 3m55,697s user 45m19,941s sys 3m7,370s Task-number: QTBUG-97601 Pick-to: 6.3 Change-Id: Ia8e37a58937568a7ed21cfeb4b27274deca4d53b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QMetaType: add a missing check for null d_ptrThiago Macieira2022-01-181-1/+1
| | | | | | | | | | | | | Bug introduced in 6.0. This is the only unprotected d_ptr I could find. [ChangeLog][QtCore][QMetaType] Fixed a bug that would cause QMetaType::compare() and QVariant::compare() to crash on invalid meta types and variants. Pick-to: 6.2 6.3 Fixes: QTBUG-99960 Change-Id: I0e5f6bec596a4a78bd3bfffd16cb1f7b2d146688 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmetatype: Fix incorrect more than one typedef warningJonas Kvinge2022-01-171-1/+1
| | | | | | | | | | | | | | The names are the keys of a hash so they can come in any order. That means the loop above, which stops before the end if it finds a name that is not the official one, may not have seen the official yet. If it has reached the end, then there is no typedef alias. Fixes: QTBUG-99620 Pick-to: 6.2 6.3 Change-Id: I3bd638766c494b32c665190d01db15c4cbc587b5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QMetaType: Allow conversion of derived gadget types to their base typesUlf Hermann2022-01-131-5/+11
| | | | | | | | A derived gadget has an is-a relationship with its base type. It should be convertible. In fact, canConvert() already tells us it is. Change-Id: I71a5ac9afd78e88adb23b4d0e757f34077f63207 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QVariant: fix incorrect warning about duplicated alias where there isn'tThiago Macieira2022-01-121-0/+1
| | | | | | | | | | | | | | We were always matching a type name to itself because we forgot to advance the iterator after we did match. The issue was introduced in commit 46dc8e453ae1d0c1eb749cfebe686995f3a6cfd0. Fixes: QTBUG-99620 Task-number: QTBUG-96916 Pick-to: 6.3 6.2 Change-Id: Ib42b3adc93bf4d43bd55fffd16c8a5df6306e404 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Jonas Kvinge <jonas@jkvinge.net>
* QVariant: use a typedef name when saving user types to QDataStreamThiago Macieira2021-12-171-1/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Due to the way Qt 5 and 6 registered type names, they end up producing different type names for the same content for a typedef. For example, because Q_DECLARE_METATYPE can't manage a comma (it's a macro), users are forced to write something like: using MyTypeMap = QMap<QString, MyType> Q_DECLARE_METATYPE(MyTypeMap) Qt 5's Q_DECLARE_METATYPE's argument "MyTypeMap" was the only name we knew about the type, so that's what got saved in the stream. However, Qt 6 QtPrivate::typenameHelper is much more clever and obtains the name from the compiler itself, so it "sees through" the typedef and registers "QMap<QString,MyType>" as the official type name. If another library/plugin has a different typedef name for the same type (e.g., StringTypeMap), it's indeterminate which type gets saved and will even change from run to run (depends on the QHash order). [ChangeLog][QtCore][QDataStream] If QDataStream is used with a QDataStream::Version < Qt_6_0 to serialize a user type that was registered via a typedef with the metatype system, the typedef's name is used in the stream instead of the non-typedef name. This restores compatibility with Qt 5, allowing existing content to read the same QDataStreams; reading from older Qt 6 versions should not be affected. (Note: if more than one typedef name is registered, it's indetermine which name gets used) Fixes: QTBUG-96916 Pick-to: 6.3 6.2 Change-Id: I2bbf422288924c198645fffd16a8d811aa58201e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QMetaType: port the BC fix for id() to new QT_REMOVED_SINCEMarc Mutz2021-12-061-14/+0
| | | | | | | The allows qmetatype.cpp compilation to enjoy PCH again. Change-Id: I47c5af33a5dbc930ee4c120b254e732c52bc2369 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmetatype.cpp: provide missing initializer for const variableThiago Macieira2021-11-101-1/+1
| | | | | | | | qmetatype.cpp(1565): warning #854: const variable "metatypeHelper" requires an initializer -- class "struct <unnamed>" has no user-provided default constructor Change-Id: I2bbf422288924c198645fffd16a9b868ff7adcb9 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QMetaType: Avoid superfluous template instantiationsFabian Kosmale2021-10-291-9/+2
| | | | | | | | | | | | Apparently msvc still parses the template and generates code for it when it encounters an extern template declaration. Thus, instead of speeding up compilation, it gets slowed down significantly as the instantiation would happen in every compilation unit that (transitively) included qmetatype.h. Task-number: QTBUG-97601 Change-Id: Id5e934afb14ad8973df1b9197aef336b22220111 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: Fix qdoc warningsVenugopal Shivashankar2021-10-231-4/+4
| | | | | | | | | | | | | | | | | src/corelib/kernel/qmetatype.cpp:1605: (qdoc) warning: Command '\snippet (//! [[implicit]])' failed at end of file 'qmetatyp> src/corelib/kernel/qmetatype.cpp:1615: (qdoc) warning: Command '\snippet (//! [[member]])' failed at end of file 'qmetatype/> src/corelib/kernel/qmetatype.cpp:1626: (qdoc) warning: Command '\snippet (//! [[memberOk]])' failed at end of file 'qmetatyp> src/corelib/kernel/qmetatype.cpp:1639: (qdoc) warning: Command '\snippet (//! [[unaryfunc]])' failed at end of file 'qmetaty> src/corelib/text/qbytearraymatcher.cpp:233: (qdoc) warning: No such parameter 'view' in QByteArrayMatcher::indexIn() src/corelib/time/qdatetime.cpp:1854: (qdoc) warning: Can't link to 'QLocaleie:pmText()' src/corelib/thread/qsemaphore.cpp:494: (qdoc) warning: Undocumented return value (hint: use 'return' or 'returns' in the text src/corelib/thread/qsemaphore.cpp:505: (qdoc) warning: Undocumented parameter 'timeout' in QSemaphore::try_acquire_for() src/corelib/thread/qsemaphore.cpp:505: (qdoc) warning: Undocumented return value (hint: use 'return' or 'returns' in the text src/corelib/thread/qsemaphore.cpp:516: (qdoc) warning: Undocumented parameter 'tp' in QSemaphore::try_acquire_until() src/corelib/thread/qsemaphore.cpp:516: (qdoc) warning: Undocumented return value (hint: use 'return' or 'returns' in the text Change-Id: Ib612c69525ec7542f2ad3dd9a07e89f266718fd8 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* corelib: Fix typos in documentationJonas Kvinge2021-10-121-1/+1
| | | | | | Pick-to: 5.15 6.2 Change-Id: I64d63af708bc6ddaabd12450eb3089e5077f849e Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QMetaType: Expand and clean up converter/view function documentationFabian Kosmale2021-09-301-14/+17
| | | | | | | | | | | | | | This adds a few snippets to show how the functions can be used, and also removes workarounds for oldver versions of qdoc that weren't clang based - those workarounds also seem to have caused some bitrot. Remove documentation for an overload of registerMutableView that currently does not exist (for a member function with an ok parameter). Fixes: QTBUG-96963 Pick-to: 6.2 Change-Id: Ibc867d08bcacbc7add8c965df9864d6f339a5d54 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QMetaTypeFunctionRegistry: avoid double-lookup in insertIfNotContains()Marc Mutz2021-08-041-2/+4
| | | | | | | | | | | | | | | | | | Because there's no insertIfNotContains()-like functionality in QHash (unlike std::unordered_map, where insert() doesn't overwrite an existing entry), the code first called contains(k) and then insert(k, ~~~), causing two lookups in the case where the insertion actually happens. Fix by using the pattern QDuplicateTracker's QSet fall-back uses, too: recording the size before and after the call to the indexing operator and using a size increase as the criterion that an insertion should happen. This reduces the number of lookups to one, at the cost of a mapped_type default construction (which, given mapped_type is std::function, should be cheap). Change-Id: I24b31107b3e26f2eea2edce7b46f8cb5e7cb35bf Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Revert "QMetaType: Don't normalize name which should already be normalized"Fabian Kosmale2021-06-091-2/+3
| | | | | | | | | | | This reverts commit f6fa4b39ee32ba4a5c6a3db5581dd50b3afc7a47. Reason for revert: c76a2d7c9cfc5e2edd45a30681df51b37125bc01 was not enough to catch all cases. Pick-to: 6.2 Change-Id: I5830ab20b1f4d26a0a201c3dd5aaee6b10aa12ac Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QMetaType: Don't normalize name which should already be normalizedFabian Kosmale2021-06-081-3/+2
| | | | | | | | | | | | | | | The name stored in a QMetaTypeInterface should already be normalized, as a static metatype uses typenameHelper, which takes care of normalization via QTypeNormalizer. For dynamic metatypes, we don't have that guarantee, but those can only be created by Qt, as there is no public API for it. We can thus ensure that we only create normalized typenames (which we currently do anyway), and skip the normalization in registerCustomType. Change-Id: I18728031825cd39fdbe17cad0fbc6e3b5fd03c93 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Doc: Use \deprecated instead of \obsoletePaul Wicking2021-05-261-6/+6
| | | | | | Task-number: QTBUG-93990 Change-Id: I4e512354a49dde6678ca89cabc56bc76ba666bb3 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Fix return type of QMetaType::sizeOf in documentationVolker Hilsheimer2021-04-071-1/+1
| | | | | | Pick-to: 6.1 Change-Id: I6f5a866fa83f0e2720d62c5170c9283997b31a7f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QMetaType::id(): Fix ABI breakageFabian Kosmale2021-03-261-0/+14
| | | | | | | | | | | | | We cannot replace a non-inline method with an inline one without breaking the ABI. Instead, we now create a version with a dummy int parameter (to avoid ODR violations), and hide the non-inline version behind an ifdef, so that it is only visible in qmetatype.cpp. Pick-to: 6.1 Change-Id: Ib4e82e44071bdf5c37227409a56d377ff2e07ee0 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QMetaType::create: don't leak memory if copy can't be madeVolker Hilsheimer2021-03-031-1/+1
| | | | | | | | | | | | | | | | | | | | QMetaType::construct will return nullptr if a copy is requested but if there is no copy constructor. In that case, the memory allocated in QMetaType::create will be leaked. This case is covered in the unit tests in template<> void testCreateHelper<QMetaType::Void>() so we can't assert in construct that a copy constructor is present if a copy is requested. Fixes static analyzer warning 618b1e6877f737df57c39fd35ad91cd4. Pick-to: 6.1 Change-Id: Ic439b36b1f120b9d0f888efaeab2801d8acc13de Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Initialize out-variableVolker Hilsheimer2021-03-031-1/+1
| | | | | | | | | | | QMetaType::convert does have code paths where nothing is written to the 'to' out-variable. Those code paths shouldn't run in this particular case, but it's good practice to initialize out-variables anyway. Fixes static analyzer warning 1453920f5abe1e30471eca6aa01d22d1. Change-Id: I6f6d1044759866c405e61cb51147ca0490c4f3a4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QMetaType: Store QMetaObject for pointer to const QObject, tooFabian Kosmale2021-02-261-0/+1
| | | | | | | | | | | | | | | | | Before this change, the QMetaType for T const* where T is derived from QObject would not store the static QMetaObject of T. This commit changes this. As a consequence, the metatype system can now convert between const and non-const pointers to QObject. Note that this allows casting const away; but so does C++ with const_cast. In addition, a new flag, QMetaType::IsImmutable is introduced, and used to tag the metatypes of pointer to const types. This allows code to discern between pointers to mutable and const QObjects, which is relevant for the QML engine. Task-number: QTBUG-82354 Change-Id: I3e4e4f39f565bd99a65e161528ce5304df73d6d6 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Assert that either both or neither pointer are nullptrVolker Hilsheimer2021-02-241-0/+10
| | | | | | | | | | | | | | If called by QMetaType::canConvert with two nullptr values, the QMETATYPE_CONVERTER_ASSIGN macro will expand to code dereferencing both 'to' and 'from' pointers. Assert that others callers provide two valid pointers. Fixes static analyzer warning 02dc34cc2ad1d4c3c6e55b44e08983f2 Pick-to: 6.1 Change-Id: I24de914faa25dc7cb1da5eae09a125506caac389 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QMetaType::id: add fastpathFabian Kosmale2021-02-181-8/+10
| | | | | | | | | This inlines the fastpath of QMetaType::id and splits the slowpath into its own function. With that change, we can also use id in operator==, simplifying the code there. Change-Id: I286fe173b43a495dbda8faa151a93895b4fd22e4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QMetaType: avoid id() calls in compareFabian Kosmale2021-02-051-2/+2
| | | | | | | | | We can avoid the overhead of the out-of-line function calls if the id is already set. As a drive-by, use relaxed loads in QMetaType::id (was: acquire). Change-Id: I1d53dbf7e58eae80776ff36334ebf0642ba7842f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Do delete on QMetaType::destroy() even without dtorUlf Hermann2021-02-011-2/+3
| | | | | | | | | As we call operator new on create(), we also need to delete on destroy(). Otherwise we leak memory. Change-Id: Ib80fe96c4173cba6fa474d3c81d88fe603d1ded2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Make QString and QByteArray sequentially iterableUlf Hermann2021-01-061-24/+40
| | | | | | | | | | | | As lists of QStrings and QByteArrays are sequentially iterable the base types should really also be. The only problem is that they don't have methods to remove items from the back or the front, but that is well within what we can support with QSequentialIterable. Change-Id: I2ab551e7b11a092aba363fb4012d131bbc4b11b4 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Add a way to check whether a metatype has datastream operatorsLars Knoll2020-12-011-1/+14
| | | | | | | | | Add QMetaType::hasRegisteredDataStreamOperators() to complement the method to check whether a data stream operator exists. Fixes: QTBUG-82916 Change-Id: Ib2f841131b7c401d5a3ae76d49104e41697c4eac Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Add a note about where to declare the streaming operatorsLars Knoll2020-12-011-1/+2
| | | | | | | | | | | | Streaming operators for types used together with QMetaType should get declared in the same namespace as the type itself because of C++s ADL rules. Add a note about that to the documentation. Pick-to: 6.0 Fixes: QTBUG-88990 Change-Id: I5d687576c6d926823dd0f1fec0743e877ae271af Reviewed-by: Robert Griebl <robert.griebl@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix documentation of QMetaType::TypeFlagAndreas Buhr2020-12-011-1/+1
| | | | | | | | | | | QMetaType::TypeFlag::IsQmlListType was renamed to QMetaType::TypeFlag::IsQmlList . This change was not reflected in the documentation. This patch adapts the documentation to this change. Task-number: QTBUG-88533 Pick-to: 6.0 Change-Id: I70be218f5f72b42aacb15ecd46972d5c808d86de Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix QVariant/QMetaType::compare APIsGiuseppe D'Angelo2020-11-301-12/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | std::optional<int> is the wrong datatype to use for compare. First and foremost, it can't be used in the idiomatic form of auto r = a.compare(b); if (r < 0) ~~~ // a is less than b if (r > 0) ~~~ // a is greater than b which we *already* feature in Qt (QString, QByteArray). Also, std::optional<int> (explicitly) converts to bool, which is a trap, because the result of the comparison can be accidentally tested as a bool: if (a.compare(b)) ~~~ // oops! does NOT mean a<b Not to mention extending this to algorithms: auto lessThan = [](QVariant a, QVariant b) { return a.compare(b); }; // oops! std::ranges::sort(vectorOfVariants, lessThan); which thankfully doesn't compile as is -- std::optional has an *explicit* operator bool, and the Compare concept requires an implicit conversion. However, the error the user is going to face will be "cannot convert to bool because the operator is explicit", which is deceiving because the fix is NOT supposed to be: auto lessThan = [](QVariant a, QVariant b) { return (bool)a.compare(b); }; // big oops! Instead: backport to Qt the required subset of C++20's <compare> API, and use that. This commits just adds the necessary parts for compare() (i.e. partial ordering), the rest of <compare> (classes, functions, conversions) can be added to 6.1. Change-Id: I2b5522da47854da39f79993e1207fad033786f00 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 3e59c97c3453926fc66479d9ceca03901df55f90) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QMetaType: Track whether type is QML list typeFabian Kosmale2020-11-231-0/+1
| | | | | | | | | This information is required in the QML engine to handle list properties (instances of QQmlListproperty<T> and list<T> types from QML). Pick-to: 6.0.0 6.0 Change-Id: I1e30572f1c91f58b290cb9b4b07433af99a1db6f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Doc: Fix various documentation issues for Qt CoreTopi Reinio2020-10-311-2/+2
| | | | | | | Task-number: QTBUG-86295 Change-Id: I3bf7d4b1533d4fc81114d353b19beaf4ea9b93b2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Make some QMetaType members constexpr and inlineLars Knoll2020-10-231-30/+5
| | | | | | | | | Since QMetaType::fromType() is constexpr, it makes sense to also make some of it's members constexpr. Change-Id: Ia2d63a904abb680ed63c1f88cb68f1d0309d029c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Rename the QMetaType::MovableType flag to RelocatableTypeLars Knoll2020-10-231-1/+2
| | | | | | | Keep this in sync with the changes we have done in QTypeInfo. Change-Id: Iaacb0f3cc5c46d3486084a1f6eca480a233d5e1a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix documentation for hidden friend operatorsVolker Hilsheimer2020-10-231-4/+2
| | | | | | | | At least for qdoc, hidden friends are class members. Change-Id: I6eaa21565937cd49c0905ee47b8b82b0c1765bc1 Reviewed-by: Topi Reiniö <topi.reinio@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Make most of QMetaTypeInterface constexprUlf Hermann2020-10-181-7/+7
| | | | | | | | | | | | | | | | | | The only thing we need to modify at runtime is the typeId and that can be mutable. This way we can have a constexpr ctor for QMetaType which hopefully makes the importing and exporting of related symbols less fickle. On Windows we cannot make QMetaTypeForType constexpr as that leads to mysterious errors in other places. Until we figure out why that is, we just leave this class as non-constexpr. This reveals that qcoreapplication.h and qvariant.h are using QDebug without including it. We now get template instantiation errors. Include qdebug.h to avoid that. Change-Id: If1bf0437ada52459c59c6fa45bab3d22dfb0bc92 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QMetaType: Avoid combination of extern and declspec(__dllexport) on MSVCUlf Hermann2020-10-121-1/+10
| | | | | | | | | MSVC does strange things with this, and it actually tells us so via a warning. We can, however, attach the dllexport to the definition, rather than the declaration of the symbols in order to resolve the problem. Change-Id: I9971e13afc6d8840c49ec20d21820a72c5407200 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Another round of replacing 0 with nullptrAllan Sandfeld Jensen2020-10-071-2/+2
| | | | | | | | | This time based on grepping to also include documentation, tests and examples previously missed by the automatic tool. Change-Id: Ied1703f4bcc470fbc275f759ed5b7c588a5c4e9f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Fix some qdoc warnings in QMetaType and QVariantVolker Hilsheimer2020-09-241-20/+15
| | | | | | | | Document new enum values, remove documentation for implicit members, fix parameters, and tie documentation to function definitions. Change-Id: I5f32d45be8709e5f614d099ddf21252e23e144f8 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Fix some qdoc warnings: function parameter namesVolker Hilsheimer2020-09-221-3/+3
| | | | | | | In QTextDocument and QTextFormat, standardize language a bit. Change-Id: I7c81ecc7a32e36ec32214e6b5386a2827cfcbc3f Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Remove default ctor for QIterableUlf Hermann2020-09-221-2/+2
| | | | | | | MSVC has strange problems with it and we don't actually need it. Change-Id: I2c443946d52d475208800f310b5f910da165c99b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QMetaType: Allow registration of mutable views and register iterablesUlf Hermann2020-09-191-45/+297
| | | | | | | | | | | | | | | In order to modify a container through an iterable, we need the original container to be mutable. The iterable, then, is not a conversion of the container, but rather a view on the container. The concept may be extended to other types. In order to facilitate this, provide a set of methods in QMetaType and QVariant similar to the convert family. The new methods are non-const and expect the original value to stay available during the life time of the view. Change-Id: I363621033f7fc600edcea2acb786820ccba49c86 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Extend QSequentialIterable and add QAssociativeIterableUlf Hermann2020-09-191-26/+39
| | | | | | | | | And add mutable iterators. This requires some refactoring of the existing iterators. Task-number: QTBUG-81716 Change-Id: I61b3a3e8c0df5fd449679257a29d9f0c3d19c4f0 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QVariant: guard usage of fromType.metaObject()Richard Moe Gustavsen2020-09-111-1/+1
| | | | | | | | | | | | | | | | This patch amends 19874d6a63. That patch caused a crash to occur when running the auto test tst_QQuickApplicationWindow::attachedProperties(). The crash can be traced back to QMetaType trying to access fromType.metaObject(), which is null. This patch will add a guard to ensure that we don't try to call a function on an object that is null. Fixes: QTBUG-86517 Change-Id: Idafd154a7b6a43e16126038fc5f9b30d7871f0d0 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>