From a68e4f3b96a82a93898f381e8ddc7f50f9c89d40 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 9 Dec 2019 10:37:28 +0100 Subject: Use the new QMetaType API in QVariant Change-Id: I5495ee1159864ebd64083fadbfac7e07177ed406 Reviewed-by: Thiago Macieira --- src/corelib/kernel/qvariant_p.h | 109 +--------------------------------------- 1 file changed, 1 insertion(+), 108 deletions(-) (limited to 'src/corelib/kernel/qvariant_p.h') diff --git a/src/corelib/kernel/qvariant_p.h b/src/corelib/kernel/qvariant_p.h index 94781a9957..aa89d42092 100644 --- a/src/corelib/kernel/qvariant_p.h +++ b/src/corelib/kernel/qvariant_p.h @@ -234,7 +234,7 @@ public: QVariantComparator(const QVariant::Private *a, const QVariant::Private *b) : m_a(a), m_b(b) { - Q_ASSERT(a->type == b->type); + Q_ASSERT(a->type() == b->type()); } template @@ -346,113 +346,6 @@ protected: const QVariant::Private *m_d; }; -template -class QVariantConstructor -{ - template::IsAccepted> - struct FilteredConstructor { - FilteredConstructor(const QVariantConstructor &tc) - { - v_construct(tc.m_x, tc.m_copy); - tc.m_x->is_null = !tc.m_copy; - } - }; - template - struct FilteredConstructor { - FilteredConstructor(const QVariantConstructor &tc) - { - // ignore types that lives outside of the current library - tc.m_x->type = QMetaType::UnknownType; - } - }; -public: - QVariantConstructor(QVariant::Private *x, const void *copy) - : m_x(x) - , m_copy(copy) - {} - - template - void delegate(const T*) - { - FilteredConstructor(*this); - } - - void delegate(const QMetaTypeSwitcher::NotBuiltinType*) - { - // QVariantConstructor is used only for built-in types. - Q_ASSERT(false); - } - - void delegate(const void*) - { - qWarning("Trying to create a QVariant instance of QMetaType::Void type, an invalid QVariant will be constructed instead"); - m_x->type = QMetaType::UnknownType; - m_x->is_shared = false; - m_x->is_null = !m_copy; - } - - void delegate(const QMetaTypeSwitcher::UnknownType*) - { - if (m_x->type != QMetaType::UnknownType) { - qWarning("Trying to construct an instance of an invalid type, type id: %i", m_x->type); - m_x->type = QMetaType::UnknownType; - } - m_x->is_shared = false; - m_x->is_null = !m_copy; - } -private: - QVariant::Private *m_x; - const void *m_copy; -}; - -template -class QVariantDestructor -{ - template::IsAccepted> - struct FilteredDestructor { - FilteredDestructor(QVariant::Private *d) - { - v_clear(d); - } - }; - template - struct FilteredDestructor { - FilteredDestructor(QVariant::Private *) - { - // It is not possible to create not accepted type - Q_ASSERT(false); - } - }; - -public: - QVariantDestructor(QVariant::Private *d) - : m_d(d) - {} - ~QVariantDestructor() - { - m_d->type = QMetaType::UnknownType; - m_d->is_null = true; - m_d->is_shared = false; - } - - template - void delegate(const T*) - { - FilteredDestructor cleaner(m_d); - } - - void delegate(const QMetaTypeSwitcher::NotBuiltinType*) - { - // QVariantDestructor class is used only for a built-in type - Q_ASSERT(false); - } - // Ignore nonconstructible type - void delegate(const QMetaTypeSwitcher::UnknownType*) {} - void delegate(const void*) { Q_ASSERT(false); } -private: - QVariant::Private *m_d; -}; - namespace QVariantPrivate { Q_CORE_EXPORT void registerHandler(const int /* Modules::Names */ name, const QVariant::Handler *handler); } -- cgit v1.2.3