diff options
author | Dominik Holland <dominik.holland@qt.io> | 2020-03-02 15:19:15 +0100 |
---|---|---|
committer | Dominik Holland <dominik.holland@qt.io> | 2020-03-02 15:19:22 +0100 |
commit | 3cb8f05175090754815dae4fbd003549c2d792eb (patch) | |
tree | f83a421d2226077c50a66ce234545c14cd575819 /src/ivicore | |
parent | 9cfe33d13bb145b774f82b2b46b936f7b3a02a71 (diff) | |
parent | c49fb8d72072eb4ba6b2f8260afa12a20301e947 (diff) | |
download | qtivi-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.cpp | 24 |
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; } |