summaryrefslogtreecommitdiff
path: root/src/ivicore
diff options
context:
space:
mode:
authorDominik Holland <dominik.holland@qt.io>2020-03-02 15:19:15 +0100
committerDominik Holland <dominik.holland@qt.io>2020-03-02 15:19:22 +0100
commit3cb8f05175090754815dae4fbd003549c2d792eb (patch)
treef83a421d2226077c50a66ce234545c14cd575819 /src/ivicore
parent9cfe33d13bb145b774f82b2b46b936f7b3a02a71 (diff)
parentc49fb8d72072eb4ba6b2f8260afa12a20301e947 (diff)
downloadqtivi-3cb8f05175090754815dae4fbd003549c2d792eb.tar.gz
Merge remote-tracking branch 'origin/5.13' into 5.14
Change-Id: Icbc626704f0cb12f84774a717e7050487a74af9c
Diffstat (limited to 'src/ivicore')
-rw-r--r--src/ivicore/qivipendingreply.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/ivicore/qivipendingreply.cpp b/src/ivicore/qivipendingreply.cpp
index 2caa926..b0c6edd 100644
--- a/src/ivicore/qivipendingreply.cpp
+++ b/src/ivicore/qivipendingreply.cpp
@@ -73,13 +73,23 @@ void qiviRegisterPendingReplyBasicTypes() {
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)
+ // This function is registered as Q_COREAPP_STARTUP_FUNCTION, which makes sure
+ // it is run after the QCoreApplication constructor to ensure we can register
+ // types.
+ // In case the library is loaded at runtime (because of a qml plugin dependency),
+ // the init function would be registered and executed right away before the
+ // rest of the library is initialized (e.g. the QMetaObject of QIviPendingReplyBase).
+ // The singleshot timer makes sure the registration is done in the next event
+ // loop run, when everything is ready.
+ QMetaObject::invokeMethod(qApp, []() {
+ 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;
}