summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Tests: check the output of QFile::openGiuseppe D'Angelo2024-03-271-1/+1
| | | | | | | | | | Wrap the call in QVERIFY. tst_QTextStream::read0d0d0a was also faulty as it *never* opened the file because of a broken path. Fix it with QFINDTESTDATA. Change-Id: I61a8f83beddf098d37fda13cb3bfb4aaa4913fc5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Change license for tests filesLucie Gérard2024-02-041-1/+1
| | | | | | | | | | | | According to QUIP-18 [1], all tests file should be LicenseRef-Qt-Commercial OR GPL-3.0-only [1]: https://contribute.qt-project.org/quips/18 Pick-to: 6.7 Task-number: QTBUG-121787 Change-Id: I9657df5d660820e56c96d511ea49d321c54682e8 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
* QMetaType: fix recursive detection of std::optional operatorsThiago Macieira2023-07-311-0/+20
| | | | | | | | | | | | | | Commit ca54b741d6edda24773137aacee229db31dd3585 used the internal has_operator_equal (and commit 01d94760d8d34e51e1442682fc151747943c7e25 copied that for has_operator_less_than) instead of using the recursive expander that was being used here. That assumed that the contained type in std::optional would always be the last final check, which is an incorrect assumption. Fixes: QTBUG-115646 Pick-to: 6.6 6.5 Change-Id: Ifbf974a4d10745b099b1fffd177702934bec27ff Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QMetaType: Provide underlyingType for enumsFabian Kosmale2023-03-281-0/+54
| | | | | | | | | | | | | | | | | | | | | | Currently, Qt assumes that enums always have int as their underlying type (both in QMetaEnum::keyToValue and in the QML engine). This change makes it possible to to retrieve the underlying type from an enum's metaype - or rather, a metatype of an integral type with the same size and signedness. The use cases aobve don't really rely on the exact same type. In most cases, we wouldn't even need the signedness, however that is already available anyway, and it will come in handy once QML supports bigint, and we need to decide whether we should return While it would be possible for individual users of this function to manually query the size and signedness, having a function returning a metatype offers additional convenience - especially in QML, where the conversion APIs generally operate on metatypes. Task-number: QTBUG-27451 Task-number: QTBUG-84055 Task-number: QTBUG-112180 Change-Id: Icf733b42df0ea64017d69f4d94cb7c855d9e3201 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QMetaType: fix value-initialization in a corner caseGiuseppe D'Angelo2022-12-301-1/+127
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a type is trivially default constructible, QMetaType (and QVariant) think that it can be built and value-initialized by zero-filling a region of storage and then "blessing" that storage as an actual instance of the type to build. This is done as an optimization. This doesn't work for all trivially constructible types. For instance, on the Itanium C++ ABI, pointers to data members are actually value-initialized (= zero-initialized, = initialized to null) with the value -1: https://itanium-cxx-abi.github.io/cxx-abi/abi.html#data-member-pointers This means that a type like struct A { int A::*ptr; }; is trivially constructible, but its value initialization is not equivalent to zero-filling its storage. Since C++ does not offer a type trait we can use for the detection that we want to do here, and since we have also decided that Q_PRIMITIVE_TYPE isn't that trait (it just means trivially copyable / destructible), I'm rolling out a custom type trait for the purpose. This type trait is private for the moment being (there's no Q_DECLARE_TYPEINFO for it), and limited to the subset of scalar types that we know can be value-initialized by memset(0) into their storage (basically, all of them, except for pointers to data members). The fix tries to keep the pre-existing semantics of `QMetaType::NeedsConstruction`. Before, the flag was set for types which were not trivially default constructible. That included types that aren't default constructible, or types that cannot do so trivially. I've left that meaning unchanged, and simply amended the "trivial" part with the custom trait. A fix there (to clarify the semantics) can be done as a separate change. Change-Id: Id8da6acb913df83fc87e5d37e2349a4628e72e91 Pick-to: 6.5 Fixes: QTBUG-109594 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Port from container.count()/length() to size()Marc Mutz2022-10-041-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is semantic patch using ClangTidyTransformator: auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o) makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'. <classes> are: // sequential: "QByteArray", "QList", "QQueue", "QStack", "QString", "QVarLengthArray", "QVector", // associative: "QHash", "QMultiHash", "QMap", "QMultiMap", "QSet", // Qt has no QMultiSet Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Compile guard tests in corelib/kernel that need threading supportMikolaj Boc2022-09-111-0/+2
| | | | | | | | | Some tests in corelib/kernel need threading support, but they are not guarded against compilation if Qt is built without threading. Such tests have been disabled in this case. Change-Id: I2f5dc9582f2a59b6af2a9e56638b045dca06193d Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* tst_qmetatype: port away from deprecated callsIvan Solovev2022-08-301-152/+232
| | | | | | | | | | | | | | | | | | | | | | | | The most common changes are: * Replace QMetaType::type("name") with QMetaType::fromName("name").id() or QMetaType::fromType<Type>().id() * QMetaType::typeName(int) -> QMetaType(int).name() * QMetaType::typeFlags(int) -> QMetaType(int).flags() * QMetaType::metaObjectForType(int) -> QMetaType(int).metaObject() * The static QMetaType::{load,save} methods are replaced with non-static versions * The static QMetaType::{create,destroy,construct, destruct} methods are guarded by QT_DEPRECATED_SINCE calls. The tests are also extended with non-static calls where they were missing. Fixed potential memory-leaks in these tests. Add separate unit-tests for deprecated APIs and guard them with QT_DEPRECATED_SINCE As a drive-by: use nullptr instead of 0 in some places Task-number: QTBUG-104858 Change-Id: I4b0cdd29bc197c186b835002372240aae3098c33 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_QMetaType: fix warning that buffer may be unusedThiago Macieira2022-07-311-2/+2
| | | | | | | | | | | | | We pass a pointer to uninitialized memory to QMetaType::create(). There's no harm because we're using the invalid QMetaType, but GCC is actually right to complain for any other type. qtestcase.h:54:25: warning: ‘buf’ may be used uninitialized [-Wmaybe-uninitialized] qmetatype.h:454:11: note: by argument 2 of type ‘const void*’ to ‘void* QMetaType::create(const void*) const’ declared here Pick-to: 6.3 6.4 Change-Id: I3859764fed084846bcb0fffd1703eb7967acf0d7 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QMetaType: don't record trivial construction function pointersThiago Macieira2022-07-271-20/+104
| | | | | | | | | | | | We can implement the trivial {default,copy,move} construction outselves inside qmetatype.cpp and qvariant.cpp, simplifying the QMetaType interface object, removing up to three relocations per QMTI. This adds the testing for QMetaType::isXxxConstructible and isDestructible that couldn't be added before. Change-Id: Ic44396b31ba04712aab3fffd16ff0a28f541d507 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QMetaType: add registerType() and qRegisterMetaType(QMetaType)Thiago Macieira2022-07-261-0/+24
| | | | | | | | | | | | | | | | | | | | | | | This also rewrites QMetaType::id() on top of the helper, with the benefit of calling a member static function, so QMetaType doesn't need to be spilled onto the stack. In some upcoming changes I need to ensure that QMetaTypes are registered so they can be found by name and I'd like to have a dedicated function name for that, instead of calling .id(). Since I needed to add docs for the new function, I've updated for the old one too. [ChangeLog][QMetaType] Added QMetaType::registerType() and an overload of qRegisterMetaType() taking QMetaType (the two functions do the same thing). These two functions ensure a given QMetaType is registered with the Qt global registry, so they can be found by name later. Using qRegisterMetaType<T>() also accomplishes the same thing, but is slightly better for completely generic code because it will avoid emitting the registration for built-in types. Change-Id: I3859764fed084846bcb0fffd170351d606034c22 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QMetaType: fix isRegistered()Thiago Macieira2022-07-261-0/+9
| | | | | | | | It's not registered until an ID is assigned. Pick-to: 6.4 Change-Id: I3859764fed084846bcb0fffd17034f5b369c5b4d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_QMetaType: suppress most warningsThiago Macieira2022-07-261-1/+16
| | | | | | | | It's not warning-free, but it's much better. Pick-to: 6.3 6.4 Change-Id: I3859764fed084846bcb0fffd170323c9ed12dd23 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_QMetaType: merge flags and flagsStaticlessThiago Macieira2022-07-261-50/+42
| | | | | | | | | And rewrite them with templates. QMetaType::typeFlags() simply calls flags() anyway. Pick-to: 6.3 6.4 Change-Id: I3859764fed084846bcb0fffd170323f9d8c80466 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Specialize MetaObjectForType for non-pointer QObject-derived typesMikolaj Boc2022-07-121-0/+1
| | | | | | | | | | | | | | | | | | QMetaTypeInterfaceWrapper tries to find the metaObjectFunction using the MetaObjectForType template. Using SFINAE, for a QObject, it should resolve to a suitable specialization. Such a specialization doesn't yet exist. It had to be created. The following path returns nullptr for registered meta types: auto metatype = QMetaType(typeId); requestedTestType.metaObject() -> returns nullptr since a bad template argument is fed to MetaObjectForType<T> in QMetaTypeInterfaceWrapper<IneritingFromQObject>::metaType's static initializer. Change-Id: I8b31c51e12cb19c333e00480b0177354b910ce1e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use SPDX license identifiersLucie Gérard2022-05-161-27/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QMetaType: Fix normalization on MSVC if name contains enumFabian Kosmale2022-05-121-0/+6
| | | | | | | | | | | | | | | During type normalization, we remove the struct, class and enum keywords (see the skipStructClassOrEnum function). However, we only want to do that for actual keywords, not for a name that happens to start with e.g. "enum", as in "enumerationNameSpacce". Adjust the MSVC check to still require no identifier character after the keyword, while still allowing for some remaining characters. Fixes: QTBUG-97813 Pick-to: 6.3 6.2 Change-Id: I82b873d02ff454cce4b75f2814a52a66f2268208 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_QMetaType: remove call to pthread_yield()Thiago Macieira2022-01-191-3/+0
| | | | | | | | | It was Linux-only and now even Linux is complaining: tst_qmetatype.cpp:421:26: warning: ‘int pthread_yield()’ is deprecated: pthread_yield is deprecated, use sched_yield instead [-Wdeprecated-declarations] Change-Id: I0e5f6bec596a4a78bd3bfffd16cb1eadfa301f16 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_QMetaType: remove the IsInitialized checkThiago Macieira2022-01-191-18/+9
| | | | | | | | | All primitive types are initialized and have been since at least commit 33cd680ddbaccf6139e215d851a39e657ae36394 ("New QMetaType representation"). Change-Id: I0e5f6bec596a4a78bd3bfffd16cb1fe22dc5c8f5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_qmetatype: add a few more row for QMetaType::UknknownTypeThiago Macieira2022-01-191-0/+23
| | | | | Change-Id: I0e5f6bec596a4a78bd3bfffd16cb215d7f6c6ddb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QMetaType: add a missing check for null d_ptrThiago Macieira2022-01-181-0/+53
| | | | | | | | | | | | | 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>
* tst_qmetatype: fix memleaksMarc Mutz2021-12-221-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | We didn't delete the new'ed up QMetaTypeInterfaces, causing asan to complain. Fix by storing them in strong references alongside their users in a statically-allocated container. We use shared_ptr to hold them, because QMetaTypeInterface doesn't have a virtual destructor, so deleting objects of the TypeInfo types (plural!) derived from QMetaTypeInterface though a pointer to the base class is UB. The shared_ptr constructor, however, is templated, so it stores the correct call (~TypeInfo()) in its type-erased deleter. We can't use std::make_shared(), because that doesn't support aggregate initialization until C++20, so we manually new up the TypeInfos. 5.15 is not affected. Pick-to: 6.3 6.2 Change-Id: Ic7ec88c34e02a9e0dd3421848c0c0885f4756702 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* tst_qmetatype: remove traces of compiler workarounds againMarc Mutz2021-12-161-5/+0
| | | | | | | | | Now that all platforms can deal with the full tst_QMetaType again, remove the last traces of the workaround. Pick-to: 6.3 Change-Id: I530cab8413f8b68903991b30a1f29b5871877a88 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_qmetatype: factor the most expensive test into its own TUMarc Mutz2021-12-071-80/+1
| | | | | | | | | | | | | | | | The PRINT_2ARD_TEMPLATE macro expansion alone is responsible for about 50% of the compile time and RAM requirements of tst_qmetatype.cpp. By factoring it into its own TU, we reduce the maximum memory load on my machine from 4.0GiB to 2.5GiB, provided we don't parallelize the build, then we take 0.5GiB more. This is a quick-fix for the QNX build problems currently plaguing the CI. Going forward, we should probably have a better solution, whatever that may be. Task-number: QTQAINFRA-4669 Change-Id: I2732b4c25b369b15cce1c7afe222d041ecb6795a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_qmetatype: move an #ifdef to the headerMarc Mutz2021-12-071-8/+0
| | | | | | | | | ... so it can be used by multiple .cpp files. Task-number: QTQAINFRA-4669 Change-Id: I7212b9b08cd3bfa44ee741ee4789d1d0024e4708 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* tst_qmetatype: Temporarily disable expensive tests on QNXFabian Kosmale2021-11-251-2/+5
| | | | | | | | | | The compiler runs out of memory and fails to compile tst_qmetatype.cpp. Set TST_QMETATYPE_BROKEN_COMPILER from a previous compiler workaround for QNX to disable the most expensive part of the test. Task-number: QTQAINFRA-4669 Change-Id: I3a99b6b790dc074e9d1db262e758555fb45e4331 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* tst_qmetatype: Fix operator< detection for std::optionalFabian Kosmale2021-09-211-0/+2
| | | | | | | | | | Amends ca54b741d6edda24773137aacee229db31dd3585. operator< is not constrained in MSVC's standard library, either. Pick-to: 6.2 Fixes: QTBUG-96690 Change-Id: Ibcbb9e53a1f9e8b13786f6d8c01489c61d8d2d7f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QTypeInfo: Handle T::value_type being equal to TFabian Kosmale2021-03-251-0/+10
| | | | | | | | | | | | | | | | | Fix operator checks for containers whose value_type equals themselves. It does not make sense to recurse on value_type in that case. Thanks to std::disjunction having short-circuiting semantics, we can avoid that issue by checking first whether T is T::value_type. As a drive-by, check for value_type typedef before checking for begin/end in is_container. This works around an issue in gcc <= 8.1, which fails to correctly SFINAE the case where begin and end are private methods. Pick-to: 6.0 6.1 Fixes: QTBUG-89456 Change-Id: I27305a7cfe050f13a279c07f00bc229c01daa25b Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* tst_qmetatype: RELOCATABLE -> PRIMITIVE is binary compatibleFabian Kosmale2021-03-051-1/+10
| | | | | | | | Based on the discussion in https://codereview.qt-project.org/c/qt/qtbase/+/336742 changing our types from RELOCATABLE to PRIMITVE is fine. Change-Id: Ica867203aa813d19fdfd3753fc4ff36ef4332fc3 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Split up the QMetaType unit testVolker Hilsheimer2021-02-091-661/+2
| | | | | | | | | | | gcc 9 consumed enourmous amounts of memory building the test, regularly dying on a VM with 4GB RAM. Splitting it up helps. As a drive-by, use inline static variables, and rename the header used by other tests to tst_qmetatype_common.h. Change-Id: Ib716d8e3506aac6c87845e57b04cb1a4f6c68387 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Replace QtTest headers with QTestDavid Skoland2020-12-221-1/+1
| | | | | | | | | | | Complete search and replace of QtTest and QtTest/QtTest with QTest, as QtTest includes the whole module. Replace all such instances with correct header includes. See Jira task for more discussion. Fixes: QTBUG-88831 Change-Id: I981cfae18a1cabcabcabee376016b086d9d01f44 Pick-to: 6.0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add a way to check whether a metatype has datastream operatorsLars Knoll2020-12-011-0/+3
| | | | | | | | | 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>
* Fix QVariant/QMetaType::compare APIsGiuseppe D'Angelo2020-11-301-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Replace discouraged Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPEAndreas Buhr2020-11-301-3/+3
| | | | | | | | | | | | | | Q_MOVABLE_TYPE was conceived before C++ had move semantics. Now, with move semantics, its name is misleading. Q_RELOCATABLE_TYPE was introduced as a synonym to Q_MOVABLE_TYPE. Usage of Q_MOVABLE_TYPE is discouraged now. This patch replaces all usages of Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPE in QtBase. As the two are synonymous, this patch should have no impact on users. Pick-to: 6.0 Change-Id: Ie653984363198c1aeb1f70f8e0fa189aae38eb5c Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QMetaType: Track whether type is QML list typeFabian Kosmale2020-11-231-19/+23
| | | | | | | | | 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>
* Make QMetaTypeInterface constexpr on WindowsLars Knoll2020-11-191-12/+23
| | | | | | | | | | | | | | | | This was so far problematic as it gave various link errors. The solution to that seems to be to make the default constructor of QPairVariantInterfaceImpl constexpr to get around one set of problems. The other problem to solve where undefined references to metaobjects. The reason for that is apparently that QMetaTypeInterface contains a direct pointer to the meta object, something the linker doesn't like. Adding a level of indirection by using a function that returns the pointer seems to solve that problem. Fixes: QTBUG-88468 Change-Id: I5612ae807ea3b7e49bc40349d8d1fca1be9bd7ee Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Get rid of Q_COMPILER_CONSTEXPR checksAllan Sandfeld Jensen2020-11-171-8/+0
| | | | | | | Is required now. Change-Id: I62e95929d1649ea1390392230b619bd56d2a0349 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Rename the QMetaType::MovableType flag to RelocatableTypeLars Knoll2020-10-231-2/+2
| | | | | | | Keep this in sync with the changes we have done in QTypeInfo. Change-Id: Iaacb0f3cc5c46d3486084a1f6eca480a233d5e1a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use qmetaobject_p.h's MetaObjectFlag in QMetaObjectBuilderEdward Welbourne2020-10-201-1/+1
| | | | | | | | This saves duplicating them with its own flags. Task-number: QTBUG-85700 Change-Id: I9e938322fd787282cfd9f941f83af8c0d76aaa9d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix compile time type normalization codeLars Knoll2020-10-141-0/+38
| | | | | | | | | | | | | | | | | | | | | Use a simpler constexpr to generate type name on gcc This works around an ICE on gcc in release mode when compiling with PCH enabled. As the type we're getting from Q_FUNC_INFO is already in a somewhat normalized form, this requires significanlty less processing and esp. not a recursive constexpr method which I suspect triggers the ICE. Fix integer type conversions to also properly normalize long long values (to q(u)longlong. Make sure the mapping also works on MSVC, where long long types get mapped to __int64. Also, normalize unsigned short and unsigned char to ushort and uchar, respectively, to follow the convention set by uint and ulong. Add some test cases to verify the mappings. Change-Id: I3dec5764450bf22ab6f066597803c3f46c2cd5ac Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Another round of replacing 0 with nullptrAllan Sandfeld Jensen2020-10-071-8/+8
| | | | | | | | | 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>
* Remove most compiler warnings about missing overridesLars Knoll2020-09-111-1/+1
| | | | | | | | | | | | Remove around 1000 compiler warnings about missing overrides in our auto tests. This significantly reduce the compiler warning noise in our auto tests, so that one can actually better see the real problems inbetween. Change-Id: Id0c04dba43fcaf55d8cd2b5c6697358857c31bf9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Reimplement QSequentialIterable using QMetaSequenceUlf Hermann2020-09-031-0/+5
| | | | | Change-Id: Ie721a5f0caa697c4bf15a81f3762cf79d3c54f5a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QWeakPointer: purge deprecated APIEdward Welbourne2020-08-311-7/+0
| | | | | | | | Since 5.0: assignment/construction from QObject pointer Since 5.14: data() to recover the packaged pointer Change-Id: I5d6ab561ce39bc0d9d3e5035eb2ca38139cd76b6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Cleanup QTypeInfoLars Knoll2020-08-261-3/+8
| | | | | | | | | | | | | | | Remove QTypeInfo::isStatic, as that's not used anymore in Qt 6. Also remove sizeOf, it's unused, and we have QMetaType for that if required. Remove all typeinfo declaractions for trivial types, as the default template covers them correctly nowadays. Finally set up a better default for isPointer, and do some smaller cleanups all over the place. Change-Id: I6758ed37dfc701feaaf0ff105cc95e32da9f9c33 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Deprecate int based convert/canConvertLars Knoll2020-08-241-2/+2
| | | | | | | Better to provide the correct meta type to convert to. Change-Id: I8e0d46e4ba482186201c157e302c03874bd38e7b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Deprecate the static int based API in QMetaTypeLars Knoll2020-08-241-8/+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>
* Remove refcounting of QMetaTypeInterfaceLars Knoll2020-08-241-6/+2
| | | | | | | | | It's only used for dynamic types in DBUS and QML, where we control things good enough to be able to handle the lifetime of those interfaces there. Change-Id: Ia7f8970d17a85b195db85fcdc2d8f1febd8753f4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove an unused enum value and document another oneLars Knoll2020-08-241-26/+27
| | | | | Change-Id: If9fed4f20242d789c1251b8798d7378d2d6911a6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Automatically register data/debug stream operations in QMetaTypeLars Knoll2020-08-241-28/+26
| | | | | | | | | | | | | | | | | | | | | | And remove the old manual registration code for those operators. Add some special handling for long/ulong, as these types could be streamed as a QVariant so far, but are not directly streamable through QDataStream. [ChangeLog][QtCore][QMetaType] The QMetaType::registerStreamOperators() and QMetaType::registerDebugStreamOperator() methods have been removed. The streaming operators for a type are now automatically registered together with the type registration. This implies that the operators should be visible wherever the type is visible and being used. [ChangeLog][Behavior Incompatible Changes] Because the QDataStream and QDebug serialization operators are automatically registered with QMetaType, the declarations of those functions must be present at any point where the type is used with QMetaType and QVariant. Change-Id: I4a0732651b20319af4a8397ff90b848ca4580d99 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>