summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qmetaobject.cpp
Commit message (Collapse)AuthorAgeFilesLines
* corelib: Fix typos in documentationJonas Kvinge2021-10-121-2/+2
| | | | | | Pick-to: 5.15 6.2 Change-Id: I64d63af708bc6ddaabd12450eb3089e5077f849e Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Fix Clang warning about loop variable creating a copyTor Arne Vestbø2021-08-261-1/+1
| | | | | Change-Id: I2a8b75294ee3bde008bcff37519da087f603ca51 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QMetaEnum: write "proper code"Marc Mutz2021-08-231-27/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rewrite keysToValue() as suggested by a comment: - Don't use the moral equivalent of QString::fromLatin1(keys).split().front().toLatin1(), use QStringTokenizer over QLatin1Strings, removing lots of allocations. - Use QL1S instead of raw char* and strcmp(), because that made the old code rely on NUL-terminated tokens after splitting, which is no longer the case when using QStringTokenizer. - Use the new stringDataView() instead of stringData() to avoid QByteArray dtors littering the code. - Extract Method parse_scope(), using high-level API operating on QL1S to see what it's actually doing, instead of previous low-level bit-pushing with char* and ints that did a good job of obfuscating the purpose of all the scanning. - Extract Method lookup() as a lambda to make the main loop of the algorithm more readable. - Extract Method className() to delay looking up the class name until it is required (and help with readability). This could be further optimized by memoizing the result, but I'm convinced that's not worth the effort. The code now no longer allocates, but we still can't mark the function as noexcept, because stringDataView() contains a Q_ASSERT, so the function has preconditions. Results show that the new code is up to 2x faster than the old, and never slower (within measurement uncertainty): PASS : tst_QMetaEnum::keysToValue(0 bits set) - 0.00042 msecs per iteration (total: 56, iterations: 131072) + 0.00012 msecs per iteration (total: 68, iterations: 524288) PASS : tst_QMetaEnum::keysToValue(1 bits set) - 0.00079 msecs per iteration (total: 52, iterations: 65536) + 0.00024 msecs per iteration (total: 63, iterations: 262144) PASS : tst_QMetaEnum::keysToValue(2 bits set) - 0.0010 msecs per iteration (total: 71, iterations: 65536) + 0.00040 msecs per iteration (total: 53, iterations: 131072) PASS : tst_QMetaEnum::keysToValue(3 bits set) - 0.0014 msecs per iteration (total: 98, iterations: 65536) + 0.00054 msecs per iteration (total: 72, iterations: 131072) PASS : tst_QMetaEnum::keysToValue(4 bits set) - 0.0017 msecs per iteration (total: 57, iterations: 32768) + 0.00074 msecs per iteration (total: 98, iterations: 131072) PASS : tst_QMetaEnum::keysToValue(5 bits set) - 0.0019 msecs per iteration (total: 65, iterations: 32768) + 0.00088 msecs per iteration (total: 58, iterations: 65536) PASS : tst_QMetaEnum::keysToValue(6 bits set) - 0.0022 msecs per iteration (total: 74, iterations: 32768) + 0.0010 msecs per iteration (total: 72, iterations: 65536) PASS : tst_QMetaEnum::keysToValue(7 bits set) - 0.0025 msecs per iteration (total: 85, iterations: 32768) + 0.0012 msecs per iteration (total: 79, iterations: 65536) PASS : tst_QMetaEnum::keysToValue(8 bits set) - 0.0027 msecs per iteration (total: 91, iterations: 32768) + 0.0012 msecs per iteration (total: 85, iterations: 65536) PASS : tst_QMetaEnum::keysToValue(9 bits set) - 0.0029 msecs per iteration (total: 98, iterations: 32768) + 0.0014 msecs per iteration (total: 97, iterations: 65536) PASS : tst_QMetaEnum::keysToValue(10 bits set) - 0.0033 msecs per iteration (total: 55, iterations: 16384) + 0.0018 msecs per iteration (total: 62, iterations: 32768) PASS : tst_QMetaEnum::keysToValue(11 bits set) - 0.0036 msecs per iteration (total: 60, iterations: 16384) + 0.0022 msecs per iteration (total: 73, iterations: 32768) PASS : tst_QMetaEnum::keysToValue(12 bits set) - 0.0036 msecs per iteration (total: 60, iterations: 16384) + 0.0018 msecs per iteration (total: 62, iterations: 32768) PASS : tst_QMetaEnum::keysToValue(13 bits set) - 0.0039 msecs per iteration (total: 64, iterations: 16384) + 0.0021 msecs per iteration (total: 70, iterations: 32768) PASS : tst_QMetaEnum::keysToValue(14 bits set) - 0.0040 msecs per iteration (total: 67, iterations: 16384) + 0.0023 msecs per iteration (total: 77, iterations: 32768) PASS : tst_QMetaEnum::keysToValue(15 bits set) - 0.0042 msecs per iteration (total: 70, iterations: 16384) + 0.0025 msecs per iteration (total: 82, iterations: 32768) PASS : tst_QMetaEnum::keysToValue(16 bits set) - 0.0053 msecs per iteration (total: 88, iterations: 16384) + 0.0028 msecs per iteration (total: 92, iterations: 32768) PASS : tst_QMetaEnum::keysToValue(17 bits set) - 0.0048 msecs per iteration (total: 80, iterations: 16384) + 0.0029 msecs per iteration (total: 97, iterations: 32768) PASS : tst_QMetaEnum::keysToValue(18 bits set) - 0.0050 msecs per iteration (total: 83, iterations: 16384) + 0.0031 msecs per iteration (total: 51, iterations: 16384) PASS : tst_QMetaEnum::keysToValue(19 bits set) - 0.0051 msecs per iteration (total: 85, iterations: 16384) + 0.0037 msecs per iteration (total: 62, iterations: 16384) PASS : tst_QMetaEnum::keysToValue(20 bits set) - 0.0053 msecs per iteration (total: 88, iterations: 16384) + 0.0041 msecs per iteration (total: 68, iterations: 16384) PASS : tst_QMetaEnum::keysToValue(21 bits set) - 0.0056 msecs per iteration (total: 92, iterations: 16384) + 0.0042 msecs per iteration (total: 69, iterations: 16384) PASS : tst_QMetaEnum::keysToValue(22 bits set) - 0.0056 msecs per iteration (total: 93, iterations: 16384) + 0.0044 msecs per iteration (total: 73, iterations: 16384) PASS : tst_QMetaEnum::keysToValue(23 bits set) - 0.0057 msecs per iteration (total: 95, iterations: 16384) + 0.0044 msecs per iteration (total: 73, iterations: 16384) PASS : tst_QMetaEnum::keysToValue(24 bits set) - 0.0060 msecs per iteration (total: 99, iterations: 16384) + 0.0062 msecs per iteration (total: 51, iterations: 8192) PASS : tst_QMetaEnum::keysToValue(25 bits set) - 0.0063 msecs per iteration (total: 52, iterations: 8192) + 0.0048 msecs per iteration (total: 80, iterations: 16384) PASS : tst_QMetaEnum::keysToValue(26 bits set) - 0.000381 msecs per iteration (total: 100, iterations: 262144) + 0.00014 msecs per iteration (total: 75, iterations: 524288) PASS : tst_QMetaEnum::keysToValue(27 bits set) - 0.00616 msecs per iteration (total: 101, iterations: 16384) + 0.0050 msecs per iteration (total: 82, iterations: 16384) PASS : tst_QMetaEnum::keysToValue(28 bits set) - 0.0062 msecs per iteration (total: 51, iterations: 8192) + 0.0051 msecs per iteration (total: 85, iterations: 16384) PASS : tst_QMetaEnum::keysToValue(29 bits set) - 0.0064 msecs per iteration (total: 53, iterations: 8192) + 0.0050 msecs per iteration (total: 82, iterations: 16384) PASS : tst_QMetaEnum::keysToValue(30 bits set) - 0.0062 msecs per iteration (total: 51, iterations: 8192) + 0.0050 msecs per iteration (total: 83, iterations: 16384) Change-Id: Idff1ef7633862beb318901352516ebb0dde3c058 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QMetaEnum: avoid quadratic behavior in valueToKeys()Marc Mutz2021-08-211-5/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QByteArray (thankfully) doesn't have the prepend "optimization", so prepend() is a linear operation, calling it in a loop thus makes the algorithm quadratic. To fix, simply remember the parts in a QVLA (an upper bound on the size of which is easily calculated) and then build the result by reverse-iterating over the QVLA. This join_reversed() function is possibly useful elsewhere, but I left it locally in the unnamed namespace to ease cherry-picking. The new stringDataView() function is more universally useful, too, and will be used in a subsequent other change. It return QL1S instead of QByteArrayView because the latter is scheduled to become a non-string type, and already lacks certain features (e.g. qTokenize() doesn't work on QBA, due to lack of a Qt::CaseSensitivity argument in QBA::indexOf()). It's also a Qt 6 addition, so not available in 5.15. We can revisit this decision later, when QBAV (or, possibly, QU8SV) has caught up. Amends 05e0dfa0060aab80afc696161226b2ab0cddfbf9. Results indicate a ~2x speedup: PASS : tst_QMetaEnum::valueToKeys(1 bits set) - 0.00026 msecs per iteration (total: 70, iterations: 262144) + 0.00017 msecs per iteration (total: 90, iterations: 524288) PASS : tst_QMetaEnum::valueToKeys(2 bits set) - 0.00037 msecs per iteration (total: 98, iterations: 262144) + 0.00019 msecs per iteration (total: 52, iterations: 262144) PASS : tst_QMetaEnum::valueToKeys(3 bits set) - 0.00040 msecs per iteration (total: 53, iterations: 131072) + 0.00021 msecs per iteration (total: 56, iterations: 262144) PASS : tst_QMetaEnum::valueToKeys(4 bits set) - 0.00047 msecs per iteration (total: 62, iterations: 131072) + 0.00022 msecs per iteration (total: 60, iterations: 262144) PASS : tst_QMetaEnum::valueToKeys(5 bits set) - 0.00048 msecs per iteration (total: 63, iterations: 131072) + 0.00024 msecs per iteration (total: 64, iterations: 262144) PASS : tst_QMetaEnum::valueToKeys(6 bits set) - 0.00061 msecs per iteration (total: 80, iterations: 131072) + 0.00027 msecs per iteration (total: 71, iterations: 262144) PASS : tst_QMetaEnum::valueToKeys(7 bits set) - 0.00063 msecs per iteration (total: 83, iterations: 131072) + 0.00027 msecs per iteration (total: 73, iterations: 262144) PASS : tst_QMetaEnum::valueToKeys(8 bits set) - 0.00069 msecs per iteration (total: 91, iterations: 131072) + 0.00030 msecs per iteration (total: 81, iterations: 262144) PASS : tst_QMetaEnum::valueToKeys(9 bits set) - 0.00070 msecs per iteration (total: 92, iterations: 131072) + 0.00031 msecs per iteration (total: 83, iterations: 262144) PASS : tst_QMetaEnum::valueToKeys(10 bits set) - 0.00074 msecs per iteration (total: 98, iterations: 131072) + 0.00034 msecs per iteration (total: 91, iterations: 262144) PASS : tst_QMetaEnum::valueToKeys(11 bits set) - 0.000762 msecs per iteration (total: 100, iterations: 131072) + 0.00035 msecs per iteration (total: 92, iterations: 262144) PASS : tst_QMetaEnum::valueToKeys(12 bits set) - 0.00088 msecs per iteration (total: 58, iterations: 65536) + 0.000381 msecs per iteration (total: 100, iterations: 262144) PASS : tst_QMetaEnum::valueToKeys(13 bits set) - 0.00094 msecs per iteration (total: 62, iterations: 65536) + 0.00038 msecs per iteration (total: 51, iterations: 131072) PASS : tst_QMetaEnum::valueToKeys(14 bits set) - 0.00099 msecs per iteration (total: 65, iterations: 65536) + 0.00041 msecs per iteration (total: 55, iterations: 131072) PASS : tst_QMetaEnum::valueToKeys(15 bits set) - 0.0010 msecs per iteration (total: 67, iterations: 65536) + 0.00042 msecs per iteration (total: 56, iterations: 131072) PASS : tst_QMetaEnum::valueToKeys(16 bits set) - 0.0010 msecs per iteration (total: 70, iterations: 65536) + 0.00044 msecs per iteration (total: 58, iterations: 131072) PASS : tst_QMetaEnum::valueToKeys(17 bits set) - 0.0011 msecs per iteration (total: 73, iterations: 65536) + 0.00046 msecs per iteration (total: 61, iterations: 131072) PASS : tst_QMetaEnum::valueToKeys(18 bits set) - 0.0012 msecs per iteration (total: 79, iterations: 65536) + 0.00048 msecs per iteration (total: 63, iterations: 131072) PASS : tst_QMetaEnum::valueToKeys(19 bits set) - 0.0012 msecs per iteration (total: 79, iterations: 65536) + 0.00051 msecs per iteration (total: 67, iterations: 131072) PASS : tst_QMetaEnum::valueToKeys(20 bits set) - 0.0012 msecs per iteration (total: 80, iterations: 65536) + 0.00054 msecs per iteration (total: 71, iterations: 131072) PASS : tst_QMetaEnum::valueToKeys(21 bits set) - 0.0012 msecs per iteration (total: 83, iterations: 65536) + 0.00090 msecs per iteration (total: 59, iterations: 65536) PASS : tst_QMetaEnum::valueToKeys(22 bits set) - 0.0012 msecs per iteration (total: 85, iterations: 65536) + 0.00057 msecs per iteration (total: 76, iterations: 131072) PASS : tst_QMetaEnum::valueToKeys(23 bits set) - 0.0013 msecs per iteration (total: 87, iterations: 65536) + 0.00059 msecs per iteration (total: 78, iterations: 131072) PASS : tst_QMetaEnum::valueToKeys(24 bits set) - 0.0014 msecs per iteration (total: 93, iterations: 65536) + 0.00065 msecs per iteration (total: 86, iterations: 131072) PASS : tst_QMetaEnum::valueToKeys(25 bits set) - 0.0014 msecs per iteration (total: 94, iterations: 65536) + 0.00063 msecs per iteration (total: 83, iterations: 131072) PASS : tst_QMetaEnum::valueToKeys(26 bits set) - 0.00028 msecs per iteration (total: 74, iterations: 262144) + 0.00017 msecs per iteration (total: 94, iterations: 524288) PASS : tst_QMetaEnum::valueToKeys(27 bits set) - 0.0014 msecs per iteration (total: 98, iterations: 65536) + 0.00063 msecs per iteration (total: 83, iterations: 131072) PASS : tst_QMetaEnum::valueToKeys(28 bits set) - 0.0014 msecs per iteration (total: 96, iterations: 65536) + 0.00065 msecs per iteration (total: 86, iterations: 131072) PASS : tst_QMetaEnum::valueToKeys(29 bits set) - 0.0014 msecs per iteration (total: 98, iterations: 65536) + 0.00064 msecs per iteration (total: 84, iterations: 131072) PASS : tst_QMetaEnum::valueToKeys(30 bits set) - 0.0014 msecs per iteration (total: 97, iterations: 65536) + 0.00064 msecs per iteration (total: 84, iterations: 131072) Pick-to: 6.2 5.15 Change-Id: Ie456b71b39c118001987716e30642f08f5e8dcdb Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QMetaEnum: stop playing ping-pong with *okMarc Mutz2021-08-181-6/+2
| | | | | | | | | | | | By dropping the clause pointlessly guarding the ranged for loop against an empty collection, we can reduce the ping-pong being played with the *ok boolean: Just set it to false at the beginning, and only set it to true when we reach the success-return. Pick-to: 6.2 Change-Id: I87365146086aba427b7414e83f077096824ff56f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QMetaEnum: stop parsing when an invalid key is foundMarc Mutz2021-08-161-1/+1
| | | | | | | | | | | | | | | | The old code obfuscated the algorithm by or'ing -1 into the return value, which is equivalent to setting it to -1 on two's complement architectures (which C++ these days requires), and happily continuing to accumulate potential keys. But nothing that can be or'ed into -1 will ever change the value, so this is rather pointless, as we're not emitting diagnostics apart from setting a bool to false. Fix by simply returning -1. That makes it obvious what we're returning, and we return early on error. Pick-to: 6.2 Change-Id: I8957f44e03609ad58d6c25d5fa78c57190b14bdd Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix qdoc warningsVolker Hilsheimer2021-05-271-1/+1
| | | | | Change-Id: Ie51ccff3272f078e062380033678828a01f03eb8 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* QMetaMethod: Store method constness in metaobject systemFabian Kosmale2021-05-071-0/+17
| | | | | | | | | [ChangeLog][QtCore][QMetaMethod] It is now possible to query the constness of a method with QMetaMethod::isConst. Change-Id: I8a94480b8074ef5b30555aeccd64937c4c6d97d4 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Introduce QMetaObject::metaTypeFabian Kosmale2021-03-251-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This function returns the metatype corresponding to the metaobject, or an invalid metatype for namespaces. This works as follows: First we increment the metaobject revision for new metaobjects. Metaobjects with older revisions are handled by doing a lookup by name. That fallback is also used for dynamic metaobjects (from QtDBUS and those created by QMetaObjectBuilder). For new metaobjects, we store the metatype in its metatype array, behind the property metatypes. This avoids any changes to the property and method metatype extraction logic: For properties, the metatype access does not change, as the new metatype is after their metatypes. For method metatypes, we already have an indirection layer (using offsets), so by adjusting those offsets by one, the same logic keeps working. To distinguish between namespaces and dynamic metaobjects, namespaces store the metatypeinterface pointer for void in the metatype array, whereas dynamic metaobjects store a nullptr. One nice additional benefit is that this simplifies the generator logic in moc, as the metatype array is now never empty. Task-number: QTBUG-92077 Change-Id: Id3f920f28553f12032a71a1a87dad29e5374dbe7 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QMetaProperty: Enable constructing only DataFabian Kosmale2020-12-011-3/+12
| | | | | | | | | | | Constructing a QMetaProperty can be unnecessarily expensive due to the QMetaEnum resolution. Add a private method to construct only QMetaProperty::Data. Make us of it in indexOfProperty. Task-number: QTBUG-82931 Change-Id: If954538106bcfaa7d088db26591f6bd6eeaf3731 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QMetaObjectPrivate: Add firstMethodFabian Kosmale2020-11-301-0/+18
| | | | | | | | | | | QMetaObject::indexfOfMethod returns the method corresponding to a specific signature. In QML, we however only want any of the methods with a given name (and do overload resolution at a later point). For this usecase this patch introduces the internal QMetaObject::firstMethod function. Change-Id: Ie3820354edffb273c4cbe1399201a955ebe79344 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QMetaProperty::typeName: use name from metatypeFabian Kosmale2020-11-301-0/+3
| | | | | | | | | | | | | | | Except for types marked as unresolved, we're doing it anyway - the only difference is that now we skip looking up the metatype by typeid. [ChangeLog][QMetaProperty][Important Behavior Change] QMetaProperty::typeName returns now always the same name as name() of the corresponding metatype. This can cause a change for enum properties which were not fully-qualified. Change-Id: I1f57743948b7262ac06095d3bbc838d620f6e481 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Standardize metaType stuff in QMetaProperty and QVariantDavid Skoland2020-11-031-0/+9
| | | | | Change-Id: Idbb03d320039e8ddc4b7a7f42d2ba93ee47c456f Reviewed-by: Lars Knoll <lars.knoll@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>
* QMetaMethod: Make comparison operators hidden friendsVolker Hilsheimer2020-10-291-4/+2
| | | | | | | Reduce ADL noise. Change-Id: Ic747c2d76b7ce66b222e08eeaf6f1d193ba99f81 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Whitespace cleanup in corelib/kernelAllan Sandfeld Jensen2020-10-241-22/+17
| | | | | Change-Id: If061ef0af5ced4384e20a82afcea3712fa7e45d7 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Deprecate QVariant::TypeLars Knoll2020-10-231-17/+6
| | | | | | | | | It's been obsolete for a long time already. Make sure the compiler now warns about it and remove all remaining uses in qtbase. Change-Id: I0ff80311184dba52d2ba5f4e2fabe0d47fdc59d7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Centralize the implementation of move assignment operatorsGiuseppe D'Angelo2020-10-031-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At the moment we have two main strategies for dealing with move assignment in Qt: 1) move-and-swap, used by "containers" (in the broad sense): containers, but also smart pointers and similar classes that can hold user-defined types; 2) pure swap, used by containers that hold only memory (e.g. QString, QByteArray, ...) as well as most implicitly shared datatypes. Given the fact that a move assignment operator's code is just boilerplate (whether it's move-and-swap or pure swap), provide two _strictly internal_ macros to help write them, and apply the macros across corelib and gui, porting away from the hand-rolled implementations. The rule of thumb when porting to the new macros is: * Try to stick to the existing code behavior, unless broken * if changing, then follow this checklist: * if the class does not have a move constructor => pure swap (but consider ADDING a move constructor, if possible!) * if the class does have a move constructor, try to follow the criteria above, namely: * if the class holds only memory, pure swap; * if the class may hold anything else but memory (file handles, etc.), then move and swap. Noteworthy details: * some operators planned to be removed in Qt 6 were not ported; * as drive-by, some move constructors were simplified to be using qExchange(); others were outright broken and got fixed; * some contained some more interesting code and were not touched. Change-Id: Idaab3489247dcbabb6df3fa1e5286b69e1d372e9 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Fix qdoc warning from QMetaObjectVolker Hilsheimer2020-09-261-1/+1
| | | | | | | It's QMetaObject::isWritable, not isReadOnly. Change-Id: I47a0b07a1969740f67c081dade3720890077361e Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Inline QMetaObject::cast(QObject *), as requested by ### Qt 6 commentEdward Welbourne2020-09-101-6/+2
| | | | | | Task-number: QTBUG-85700 Change-Id: I29405df37b82d34a92537e39a3863b5f6c998556 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix a number of MSVC integer conversion warningsFriedemann Kleint2020-09-101-5/+5
| | | | | | | | Mostly related to qstrlen(). Change-Id: I69e2052c83766e4fc466ed398d0d0eac011a77ec Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Make bindings introspectable through mocLars Knoll2020-09-021-5/+24
| | | | | | | | | | | | | | | Add a new BINDABLE declaration to the Q_PROPERTY() macro that tells moc where to find the QBindable for the property. Add a QUntypedBindable base class to QBindable<T> that gives access to generic functionality and checks argument compatibility at runtime. QBindable<T> will still do static checking at compile time. Add QMetaProperty::isBindable() and QMetaProperty::bindable() to be able to dynamically access the binding functionality. Change-Id: Ic7b08ae2cde83fd43e627d813a886e1de01fa3dc Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Improve connect: Use existing metatypes if possibleFabian Kosmale2020-08-281-0/+21
| | | | | | | | | | | As there is now a chance that a QMetaMethod already contains the metatypes for its arguments, we can just query it directly (and use the fallback to name lookup logic that already exists there). This also allows us to avoid creating a QList of names, and only requires us to do a name lookup in case the connection actually fails. Change-Id: Idda30bc4b538a94476ae6c533776c22340f0030d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use QMetaType in QMetaCallEventLars Knoll2020-08-241-5/+5
| | | | | | | And don't use int based type mapping anymore. Change-Id: I456e76d1933ef646a7bd39ce565886b89e938a44 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Clean up int based convert() APILars Knoll2020-08-241-1/+1
| | | | | | | Pass QMetaType instances instead. Change-Id: I07366cea566fdebf5bb793aa8087f8109216ec0c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Deprecate the static int based API in QMetaTypeLars Knoll2020-08-241-10/+8
| | | | | | | | | | | | | And remove one of the type id to name mapping that still existed in QMetaType. QMetaTypeInterface can provide that, so there's no need to have a second copy of the data. qMetaTypeTypeInternal() can still map all the names of all builtin types to ids. That functionality is for now still required by moc and can't be removed yet. Change-Id: Ib4f8e9c71e1e7d99d52da9e44477c9a1f1805e57 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix a number of qdoc warningsFriedemann Kleint2020-08-201-21/+8
| | | | | | | | | | | - Remove obsolete functions and enumeration values - Remove QObject * parameter from QMetaProperty accessors - Fix renamed enumerations in QSsl - Fix list items to be \li - Fix function signatures and variable names Change-Id: I37c7e6bf2c8ff92bc7b82620bae0a27796f866ab Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* QMetaObject: Compare threadIds when checking receiver threadMike Achtelik2020-06-251-9/+16
| | | | | | | | | Comparing threadIds is faster, especially if invoked from a non qt thread, where QThread::currentThread() needs to create a QAdoptedThread/QThreadData first. Pick-to: 5.15 Change-Id: I44b3013283754f1a5ac9d62debcf4c82be77c554 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Move implementation of QVector/List back to qlist.hLars Knoll2020-06-201-1/+1
| | | | | | | | | | | | | And name the main class QList. That's also the one we document. This gives less porting pain for our users, and a lot less churn in our API, as we use QList in Qt 5 in 95% of our API. In addition, it gives more consistent naming with QStringList and QByteArrayList and disambiguates QList vs QVector(2|3|4)D. Fixes: QTBUG-84468 Change-Id: I3cba9d1d3179969d8bf9320b31be2230d021d1a9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QMetaMethod: implement returnType via returnMetaTypeFabian Kosmale2020-06-181-3/+1
| | | | | Change-Id: I6c77331c3bfe83b00e4bbdf960216df696aadabd Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Add some support to flag alias propertiesLars Knoll2020-06-111-0/+14
| | | | | | | | | | | This is required if we want to be able to get rid of the property cache. Also reserve a flag for var properties, in case it turns out that we need to keep the distinction between var and QVariant properties in QML. Change-Id: I55c2191adcc2d94bd8f148216e26423defaa900f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Get rid of the obsolete isEditable flag for propertiesLars Knoll2020-06-111-21/+0
| | | | | | Change-Id: I54411bd8e223671523c9c8fad5c80bfa6b5b7097 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Further metaobject cleanupsFabian Kosmale2020-06-111-32/+34
| | | | | | | | | | | Remove QMetaProperty index member. Instead, add a function to compute it on demand from the QMetaObject. Also remove the remains of the signature function. Original-patch-by: Lars Knoll <lars.knoll@qt.io> Change-Id: I5b16d444e7474216a535e3e93a118825cd0e6090 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Cleanup QMetaClassInfoLars Knoll2020-06-111-3/+3
| | | | | Change-Id: I0b4fa4568f8479106053e0fae72fc802fca74a65 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Cleanups in QMetaPropertyFabian Kosmale2020-06-111-132/+86
| | | | | | | | | This changes the layout of the meta object data, so also bump the meta object revision. Original-patch-by: Lars Knoll <lars.knoll@qt.io> Change-Id: I176fb16c207e8ebe59e358e69554be813406232f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Qt6: remove support for property flags being functionsLars Knoll2020-06-111-44/+14
| | | | | | | | | | | | | | | Property flags should be compile time booleans, not something to be determined at runtime. We've been using this to dynamically disable some properties in QWidget based classes dependent on the state of a different property, but this should better get implemented on top of our widgets. Change-Id: I6296e8761303ecdf24d9e842142e8596304c015d Reviewed-by: Simon Hausmann <hausmann@gmail.com> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Clean up QMetaEnum codeLars Knoll2020-06-111-56/+35
| | | | | | Change-Id: I9c1fcfd72890fb3d69d2d9caed7f3cff931c3ff6 Reviewed-by: Simon Hausmann <hausmann@gmail.com> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QMetaMethod: clean up offset handlingLars Knoll2020-06-111-39/+60
| | | | | | | | | | | | Centralize the offset handling in one place and avoid lots of magic numbers in various places. Expose the number of ints per method in QMetaObjectPrivate as a constant, so that code in other places can access it via private API. Change-Id: I59790287a17ea47e6160ec65d9c8d0aaee748947 Reviewed-by: Simon Hausmann <hausmann@gmail.com> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Port QMetaObject away from QStringRefLars Knoll2020-06-101-3/+3
| | | | | | Task-number: QTBUG-84319 Change-Id: I905c2e1780a2ec42b1d189494bd5399e124df354 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* MetaObject: Store the QMetaType of the methodsFabian Kosmale2020-06-021-25/+55
| | | | | | | | | | | | | | | | | | | | | | | | This does the analog of 46f407126ef3e94d59254012cdc34d6a4ad2faf2 for the methods we care about (signals, slots, Q_INVOKABLEs). In addition to the actual QMetaType, we store an array with offsets so that we later can do a mapping from methodIndex to metatype. The newly added QMetaMethod::{return,parameter}MetaType methods can then be used to retrieve the metatypes. This does however require that all involved types are complete. This is unfortunately not a feasible requirement. Thus, we only populate the metatype array on a best effort basis. For any incomplete type, we store QMetaType::Unknown. Then, when accessing the metatype, we fall back to the old string based code base if it's Unknown. Squashes "moc: support incomplete types" and "Fix compile failures after QMetaMethod change" Fixes: QTBUG-82932 Change-Id: I6b7a587cc364b7cad0c158d6de54e8a204289ad4 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Cosmetic whitespace / indentationIvan Tkachenko2020-05-291-32/+43
| | | | | | | | | | Split long signature into multiple lines, and indent some existing misaligned signatures. Change-Id: Icaed7b703c3f0b20472400b186ac2a28f1ff1dd1 Pick-to: 5.15 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-04-081-0/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: examples/opengl/doc/src/cube.qdoc src/corelib/global/qlibraryinfo.cpp src/corelib/text/qbytearray_p.h src/corelib/text/qlocale_data_p.h src/corelib/time/qhijricalendar_data_p.h src/corelib/time/qjalalicalendar_data_p.h src/corelib/time/qromancalendar_data_p.h src/network/ssl/qsslcertificate.h src/widgets/doc/src/graphicsview.qdoc src/widgets/widgets/qcombobox.cpp src/widgets/widgets/qcombobox.h tests/auto/corelib/tools/qscopeguard/tst_qscopeguard.cpp tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro tests/manual/diaglib/debugproxystyle.cpp tests/manual/diaglib/qwidgetdump.cpp tests/manual/diaglib/qwindowdump.cpp tests/manual/diaglib/textdump.cpp util/locale_database/cldr2qlocalexml.py util/locale_database/qlocalexml.py util/locale_database/qlocalexml2cpp.py Resolution of util/locale_database/ are based on: https://codereview.qt-project.org/c/qt/qtbase/+/294250 and src/corelib/{text,time}/*_data_p.h were then regenerated by running those scripts. Updated CMakeLists.txt in each of tests/auto/corelib/serialization/qcborstreamreader/ tests/auto/corelib/serialization/qcborvalue/ tests/auto/gui/kernel/ and generated new ones in each of tests/auto/gui/kernel/qaddpostroutine/ tests/auto/gui/kernel/qhighdpiscaling/ tests/libfuzzer/corelib/text/qregularexpression/optimize/ tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/ tests/libfuzzer/gui/text/qtextdocument/sethtml/ tests/libfuzzer/gui/text/qtextdocument/setmarkdown/ tests/libfuzzer/gui/text/qtextlayout/beginlayout/ by running util/cmake/pro2cmake.py on their changed .pro files. Changed target name in tests/auto/gui/kernel/qaction/qaction.pro tests/auto/gui/kernel/qaction/qactiongroup.pro tests/auto/gui/kernel/qshortcut/qshortcut.pro to ensure unique target names for CMake Changed tst_QComboBox::currentIndex to not test the currentIndexChanged(QString), as that one does not exist in Qt 6 anymore. Change-Id: I9a85705484855ae1dc874a81f49d27a50b0dcff7
| * Warn that the EDITABLE flag for property declarations is deprecatedLars Knoll2020-04-021-0/+2
| | | | | | | | | | | | | | Additionally mark QMetaProperty::isEditable as deprecated. Change-Id: I1abe4c6f2d30c2f96380f9e5942be431dbfed38f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Add support for exposing public QProperty members in the meta-object systemSimon Hausmann2020-03-181-0/+15
| | | | | | | | | | | | | | | | | | | | At the moment this makes the type as well as the setter/getter available through the meta-call as well as the ability to register observers and bindings. Only QProperty members that are annotated with Q_PROPERTY(type name) are made public through the meta-object. Change-Id: I16b98fd318122c722b85ce61e39975284e0c2404 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | MetaObject: store the QMetaType of the propertiesOlivier Goffart2020-02-251-116/+38
| | | | | | | | | | Change-Id: I563e7232b70e94de4184f2c23a581319313dcf5c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Normalize types at compile timeOlivier Goffart2020-02-201-11/+1
| | | | | | | | | | | | | | | | | | | | This also fix the normalization algorithm: - Some 'const' after pointers were not removed as they should. - No need to keep the space in '> >' and '< :' in C++11 anymore - Fix normalization of 'long unsigned int' and similar Change-Id: I2b72f0fede96c1063e7b155d9f25a85fccfc7bf9 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-01-281-8/+23
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qsettings.cpp src/corelib/kernel/qvariant.cpp src/corelib/serialization/qjsoncbor.cpp src/corelib/serialization/qjsonvalue.cpp src/corelib/tools/tools.pri src/gui/image/qimage.cpp src/gui/kernel/qguivariant.cpp src/widgets/kernel/qshortcut.cpp tests/auto/tools/moc/allmocs_baseline_in.json tests/auto/tools/moc/tst_moc.cpp src/opengl/qglframebufferobject.cpp Done-With: Edward Welbourne <edward.welbourne@qt.io> Done-With: Leander Beernaert <leander.beernaert@qt.io> Change-Id: Ie7f5fa646c607fe70c314bf7195f7578ded1d271
| * Doc: Replace some usages of 0/zero/null with \nullptrSze Howe Koh2020-01-271-2/+2
| | | | | | | | | | Change-Id: Ibe7de11fc6fc41477c35e7d653c6a911855deabb Reviewed-by: Paul Wicking <paul.wicking@qt.io>
| * Introduce Q_PROPERTY attribute REQUIREDFabian Kosmale2020-01-231-0/+15
| | | | | | | | | | | | | | | | This is meant to correspond to required properties in QML. Change-Id: I2645981e13f7423bc86b48370c165b3cfe2aaa62 Task-number: QTBUG-81561 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
| * Replace most use of QVariant::type and occurrences of QVariant::TypeOlivier Goffart2020-01-231-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I made a clazy automated check that replaced the use of QVariant::Type by the equivalent in QMetaType. This has been deprecated since Qt 5.0, but many uses were not yet removed. In addition, there was some manual changes to fix the compilation errors. Adapted the Private API of QDateTimeParser and QMimeDataPrivate and adjust QDateTimeEdit and QSpinBox. QVariant(QVariant::Invalid) in qstylesheet made no sense. But note that in QVariant::save, we actually wanted to use the non-user type. In the SQL module, many changes were actually reverted because the API still expects QVarient::Type. Change-Id: I98c368490e4ee465ed3a3b63bda8b8eaa50ea67e Reviewed-by: Lars Knoll <lars.knoll@qt.io>