diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-07-15 21:21:05 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-08-24 00:18:58 +0200 |
commit | 92b37676328a960bc092b1f3834233c550376457 (patch) | |
tree | ac75c61314238e7a6b24751f20d47a222ed97f08 /src/corelib/kernel/qmetatype.h | |
parent | d0ccb3aaf9052fc20cee08c825d8ccc9ac02fe8e (diff) |
Remove refcounting of QMetaTypeInterface
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>
Diffstat (limited to 'src/corelib/kernel/qmetatype.h')
-rw-r--r-- | src/corelib/kernel/qmetatype.h | 41 |
1 files changed, 13 insertions, 28 deletions
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 3a536ae0e0..cbf1e19187 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -377,17 +377,8 @@ public: static void destruct(int type, void *where); explicit QMetaType(int type); - explicit QMetaType(QtPrivate::QMetaTypeInterface *d); - constexpr QMetaType() : d_ptr(nullptr) {} - ~QMetaType(); - QMetaType(const QMetaType &other) : QMetaType(other.d_ptr) {} - QMetaType &operator=(const QMetaType &); - QMetaType(QMetaType &&other) : d_ptr(other.d_ptr) { other.d_ptr = nullptr; } - QMetaType &operator=(QMetaType &&other) - { - qSwap(d_ptr, other.d_ptr); - return *this; - } + explicit constexpr QMetaType(QtPrivate::QMetaTypeInterface *d) : d_ptr(d) {} + constexpr QMetaType() = default; bool isValid() const; bool isRegistered() const; @@ -566,6 +557,10 @@ public: #endif static bool registerConverterFunction(const ConverterFunction &f, int from, int to); static void unregisterConverterFunction(int from, int to); + + static void unregisterMetaType(QMetaType type); + QtPrivate::QMetaTypeInterface *iface() { return d_ptr; } + private: friend class QVariant; QtPrivate::QMetaTypeInterface *d_ptr = nullptr; @@ -1922,20 +1917,14 @@ namespace QtPrivate { class QMetaTypeInterface { public: - uint revision; // 0 in Qt 6.0. Can increase if new field are added + ushort revision; // 0 in Qt 6.0. Can increase if new field are added + ushort alignment; uint size; - uint alignment; uint flags; + QBasicAtomicInt typeId; const QMetaObject *metaObject; const char *name; - QBasicAtomicInt typeId; - QtPrivate::RefCount ref; - - // Called when the type is unregistered, to delete this - using DeleteSelf = void (*)(QMetaTypeInterface *); - DeleteSelf deleteSelf; - using DefaultCtrFn = void (*)(const QMetaTypeInterface *, void *); DefaultCtrFn defaultCtr; using CopyCtrFn = void (*)(const QMetaTypeInterface *, void *, const void *); @@ -2504,14 +2493,12 @@ public: template<typename T> QMetaTypeInterface QMetaTypeForType<T>::metaType = { /*.revision=*/ 0, - /*.size=*/ sizeof(T), /*.alignment=*/ alignof(T), + /*.size=*/ sizeof(T), /*.flags=*/ QMetaTypeTypeFlags<T>::Flags, + /*.typeId=*/ BuiltinMetaType<T>::value, /*.metaObject=*/ MetaObjectForType<T>::value(), /*.name=*/ getName(), - /*.typeId=*/ BuiltinMetaType<T>::value, - /*.ref=*/ Q_REFCOUNT_INITIALIZE_STATIC, - /*.deleteSelf=*/ nullptr, /*.defaultCtr=*/ getDefaultCtr<T>(), /*.copyCtr=*/ getCopyCtr<T>(), /*.moveCtr=*/ getMoveCtr<T>(), @@ -2536,14 +2523,12 @@ public: static inline QMetaTypeInterface metaType = { /*.revision=*/ 0, - /*.size=*/ 0, /*.alignment=*/ 0, + /*.size=*/ 0, /*.flags=*/ 0, + /*.typeId=*/ BuiltinMetaType<void>::value, /*.metaObject=*/ nullptr, /*.name=*/ "void", - /*.typeId=*/ BuiltinMetaType<void>::value, - /*.ref=*/ Q_REFCOUNT_INITIALIZE_STATIC, - /*.deleteSelf=*/ nullptr, /*.defaultCtr=*/ nullptr, /*.copyCtr=*/ nullptr, /*.moveCtr=*/ nullptr, |