aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-04-28 20:58:40 +0200
committerUlf Hermann <ulf.hermann@qt.io>2021-04-28 22:34:54 +0200
commit78cb5de03db97ddc7f62e3e256ebfdd47ce3aae5 (patch)
treed62691cf6d120a8297a9c6ae97c50764c979abcf
parent768a6415b596e557cd84ffb56c3aa0e32645aa2f (diff)
Initialize the metatypes of extensions
If we don't do that we can't look up the extension metatypes by name or by ID, which is very inconvenient. Change-Id: Ie93df186908c38de80a2f0b7c06c4df93cb4c5af Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
-rw-r--r--src/qml/qml/qqmlprivate.h3
-rw-r--r--tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp1
-rw-r--r--tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h10
3 files changed, 14 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlprivate.h b/src/qml/qml/qqmlprivate.h
index cebbf47fdb..a98427d594 100644
--- a/src/qml/qml/qqmlprivate.h
+++ b/src/qml/qml/qqmlprivate.h
@@ -905,6 +905,9 @@ namespace QQmlPrivate
qmlTypeIds
};
+ // Initialize the extension so that we can find it by name or ID.
+ qMetaTypeId<E>();
+
qmlregister(TypeAndRevisionsRegistration, &type);
}
diff --git a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp
index 562eb3298b..4de68ed7d8 100644
--- a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp
+++ b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp
@@ -152,6 +152,7 @@ void tst_qmltyperegistrar::metaTypesRegistered()
verifyMetaType("Ooo*", "Ooo");
verifyMetaType("Bbb*", "Bbb");
verifyMetaType("Ccc*", "Ccc");
+ verifyMetaType("SelfExtensionHack", "SelfExtensionHack");
}
void tst_qmltyperegistrar::multiExtensions()
diff --git a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h
index a6ac54aa9e..c0657eaf56 100644
--- a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h
+++ b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h
@@ -34,6 +34,7 @@
#include <QtQml/qqml.h>
#include <QtCore/qproperty.h>
#include <QtCore/qtimeline.h>
+#include <QtCore/qrect.h>
class Interface {};
class Interface2 {};
@@ -272,6 +273,15 @@ class HiddenAccessors : public QObject
Q_DECLARE_PRIVATE(HiddenAccessors)
};
+struct SelfExtensionHack
+{
+ QRectF rect;
+ Q_GADGET
+ QML_EXTENDED(SelfExtensionHack)
+ QML_FOREIGN(QRectF)
+ QML_VALUE_TYPE(recterei)
+};
+
class tst_qmltyperegistrar : public QObject
{
Q_OBJECT