aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominik Holland <dominik.holland@qt.io>2020-01-09 15:58:11 +0100
committerDominik Holland <dominik.holland@qt.io>2020-01-14 12:20:46 +0000
commite11701cd49210033ff64577417df50dadd0b2c83 (patch)
tree9cbda4dc632a3fb6f799374f64a420aa01c5ab31
parent7ddf165e3fa8130c7a0b702a727d4238ddab35bb (diff)
Register all basic PendingReply types on the first use
Change-Id: I50b0b4bbe98272c2a6d617f7b7c62cb906d6fe81 Reviewed-by: Robert Griebl <robert.griebl@qt.io>
-rw-r--r--src/ivicore/qivipendingreply.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/ivicore/qivipendingreply.cpp b/src/ivicore/qivipendingreply.cpp
index 1780058..e7766f4 100644
--- a/src/ivicore/qivipendingreply.cpp
+++ b/src/ivicore/qivipendingreply.cpp
@@ -59,18 +59,20 @@ QT_BEGIN_NAMESPACE
#define QTIVI_ADD_STATIC_METATYPE(MetaTypeName, MetaTypeId, AliasingType) \
QTIVI_ADD_STATIC_METATYPE2(MetaTypeName, MetaTypeId, AliasingType, nullptr)
-struct QIviPendingReplyRegistrator {
- QIviPendingReplyRegistrator() {
- qRegisterMetaType<QIviPendingReplyBase>("QIviPendingReplyBase");
- QT_FOR_EACH_STATIC_PRIMITIVE_TYPE(QTIVI_ADD_STATIC_METATYPE)
- QT_FOR_EACH_STATIC_PRIMITIVE_POINTER(QTIVI_ADD_STATIC_METATYPE)
- QT_FOR_EACH_STATIC_CORE_POINTER(QTIVI_ADD_STATIC_METATYPE)
- QT_FOR_EACH_STATIC_CORE_TEMPLATE(QTIVI_ADD_STATIC_METATYPE)
- QT_FOR_EACH_STATIC_CORE_CLASS(QTIVI_ADD_STATIC_METATYPE)
- QT_FOR_EACH_STATIC_ALIAS_TYPE(QTIVI_ADD_STATIC_METATYPE2)
- }
-};
-static QIviPendingReplyRegistrator _registrator;
+static void qiviRegisterPendingReplyBasicTypes() {
+ static bool once = false;
+ if (once)
+ return;
+
+ qRegisterMetaType<QIviPendingReplyBase>("QIviPendingReplyBase");
+ QT_FOR_EACH_STATIC_PRIMITIVE_TYPE(QTIVI_ADD_STATIC_METATYPE)
+ QT_FOR_EACH_STATIC_PRIMITIVE_POINTER(QTIVI_ADD_STATIC_METATYPE)
+ QT_FOR_EACH_STATIC_CORE_POINTER(QTIVI_ADD_STATIC_METATYPE)
+ QT_FOR_EACH_STATIC_CORE_TEMPLATE(QTIVI_ADD_STATIC_METATYPE)
+ QT_FOR_EACH_STATIC_CORE_CLASS(QTIVI_ADD_STATIC_METATYPE)
+ QT_FOR_EACH_STATIC_ALIAS_TYPE(QTIVI_ADD_STATIC_METATYPE2)
+ once = true;
+}
// TODO make it reentrant
@@ -561,6 +563,7 @@ void QIviPendingReplyWatcher::then(const QJSValue &success, const QJSValue &fail
QIviPendingReplyBase::QIviPendingReplyBase(int userType)
: m_watcher(new QIviPendingReplyWatcher(userType))
{
+ qiviRegisterPendingReplyBasicTypes();
}
QIviPendingReplyBase::QIviPendingReplyBase(const QIviPendingReplyBase &other)