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 the arguments that are nowadays unused.
Change-Id: I97ed983b158aba57653f35e7e2f91f5c79dace8c
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Move the last functionality it had (casting between QObject
derived types) over to QMetaType. Now qvariant_cast<> is
nothing but a wrapper around QMetaType::convert().
Change-Id: Iab02b6b97c141d64052823646e18227d1eb403dd
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Those were not yet supported by QMetaType.
Change-Id: I9f85476049f200e35939ac58ef7e8b4e7cbe0b77
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Use the fact that we return the conversion function as a lambda
to find out reliably whether a conversion between two types
can be done.
This requires some minor adjustments to our tests:
* Nothing can convert to an unknown type and vice versa
* Adjust results to the fact that we don't convert from char
to QString anymore (where the old method was incorrect)
* QStringList->QString requires some adjustments, as we only
convert if the string list has exactly one element. For now
we return true in canConvert(), but the conversion behavior
in this case is something we should rethink, as it is very
surprising.
Change-Id: I3f5f87ee9cb99d690f5a7d13b13d6a6313d8038e
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
All conversions do now happen through QMetaType::convert().
Change-Id: I70f7a883262087768acccf8361d34c0490ff2b43
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Take the opportunity to properly handle the underlying type
(size and signed vs unsigned).
Change-Id: I0cb8cf40acac6de03c24ed3fe570db68268952c8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This will ensure full symmetry in what QVariant and
QMetaType support. With this done, QVariant will become
simply a container that can hold any QMetaType with fully
symmetric functionality between both.
Change-Id: I796d4368a2bc0f08cf4f70f4465ed6a0e07bdd76
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
This helps get better symmetry with the other modules,
and to unify the code paths for both conversion and
retrieving the interface for static types.
Change-Id: Icbd20de2563f36e3de20d826323acd057734abfb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Always ask QMetaType to convert first before trying the builtin
code in QVariant. That way we can migrate conversions piece by
piece to QMetaType.
Change-Id: I4fd1bad3ef045d37f84f68e748a6357e0ee0c16c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Avoid some atomic operations by using this instead
of type().id().
Change-Id: Ic664794908d3a9fc3686f954b582740b73c052c6
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Remove all the internal members of the union. Instead replace
it with raw storage (uchar[]) aligned to max_align_t.
Place all accesses to the internal members with get<> methods
for consistency.
Change-Id: Icebf46b90c9375aa6ea0b5913b2132608e8c223d
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Replace it with QVariant::Private::get<>().
Change-Id: I801742300d9b15f748bb91fcd6cfa176d2057271
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Adds convenient access to the data from the Private pointer.
data() determines the storage location at run time, get()
at compile time. internalStorage() can be used if we're accessing
one of multiple types, but know that the type is stored internally.
typeId() is an optimization as it allows retrieving the type id
of the metatype without atomic refcounting operations (which
type().id() would be doing).
Change-Id: I39a508c530a1588053248607c8932e501fd474dc
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Move the type conversions from QVariant::Helper to QMetaType. Only do
this for Qt Gui in a first step.
This makes it possible to completely remove the Handler struct in
QVariant, and now allows QMetaType to also convert Gui types.
Moving the conversion of Core types into QMetaType will require
further work.
Change-Id: I061f789deca1b595d92bb29227eb54b8e71a3ee3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Use std::function to register the converter functions
instead of our own handrolled interface.
Change-Id: Ifc1d1d383d21ee8d4239dbc3970c1f31bf0f4037
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
That parameter is duplicating the return value, get rid of it.
Change-Id: I8d6ecee8aca90aecaf08e6d0072d83e9a08ce3d6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Streamline code using if constexpr and remove some unused code paths.
Change-Id: I602acffab4b3e53fab9e2433856f6b7e8210cc60
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This should speed up quite some of the QVariant operations
Change-Id: Ifae2df39e47e2e1ef1d9a947802bdd17fc66aa66
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Remove the additional indirection through ptr and replace
it with an offset calculation. Get rid of PrivateSharedEx
that was handling certain types differently.
This also fixes the support for overaligned types, by
using the alignment field from QMetaType to determine
the alignment requirements.
Change-Id: Icc6a78eb57f664c7747450578fe58dfee8f2863b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
There's no point in storing small types with an external
refcount, even if they aren't movable. Simply copying
the type should be faster in pretty much all cases, while
this uses less memory.
Change-Id: I127474f8e3c5fa042f530684f9d5bfccbba134ca
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
There is no need to generate wrapper functions for equals,
lessThan or debugStream for pointer types, as those can
easily be handled by a few lines of code in QMetaType itself.
Change-Id: If79b3bc3a629249c1d17c9e592202f08b59f80ef
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Refactor the methods retrieving data in Q*Iterable so
that we don't return pointers with unclear ownership. Instead,
copy the data into a out pointer provided by the caller.
This also means there is no need for the metatype flags
anymore and we can remove those.
Change-Id: I517de23a8ccfd608585ca00403aca0df2955f14b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Store a QMetaType, not a meta type id in the classes.
Change-Id: If27a60512a46fa029cc914d65b8cad7f89d7f3b0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Remove the old revision of the interface, this is not
required with Qt 6 anymore, as everything is being
recompiled anyway.
Change-Id: I66070c4dc6b5e2a6d22f5a9ebea7688ed38333fe
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This code is now unused, as streaming operators are
registered automatically.
Change-Id: I0e48944c33a92cf1f2f158fb2dc0ca49256d7938
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Use the builtin support in QMetaType instead.
Change-Id: Ifc0e88719a384aa7fb525652bada22b6f7ee1c45
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
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>
We shouldn't rely on include path containing also /QtCore
Task-number: QTBUG-82615
Change-Id: I0f98f6097865cc5aa2c2fc9a0fabf2c4513b7afe
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
I'm pretty sure we want to keep supporting statements like
bool ok = connect(~~~);
that is, statements that do use copy initialization and not
direct initialization. As such, QMetaObject::Connection has
to keep using the restricted bool trick and cannot be ported
over to explicit operator bool.
Change-Id: I07a38f7c134686e67b5984aa93fe5cf3201561d7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
The debug feature for the CMake build is solely determined by the value of
CMAKE_BUILD_TYPE or CMAKE_CONFIGURATION_TYPES. There is no point in
restricting the autoDetect expression to developer builds or MSVC and
macOS builds.
User-visible result: -DCMAKE_BUILD_TYPE=Debug now actually turns the
'debug' feature on, also for non-developer builds on Linux.
Change-Id: I65c92575c9483bff16beb78b60606c55aeadcece
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>