From b3980dd12357619241e3958160f8e3d9cdceb54f Mon Sep 17 00:00:00 2001 From: Victor Tran Date: Tue, 2 Apr 2024 11:32:52 +1100 Subject: [PATCH] Don't optimise out QML registration function --- .../CoreStyles/contemporarystyleplugin.cpp | 7 +++++-- .../Contemporary/CoreStyles/contemporarystyleplugin.h | 9 ++++----- .../Contemporary/impl/contemporaryimplstyleplugin.cpp | 5 ++++- .../Contemporary/impl/contemporaryimplstyleplugin.h | 11 +++++------ 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/controls/com/vicr123/Contemporary/CoreStyles/contemporarystyleplugin.cpp b/controls/com/vicr123/Contemporary/CoreStyles/contemporarystyleplugin.cpp index de66db8..3fbb728 100644 --- a/controls/com/vicr123/Contemporary/CoreStyles/contemporarystyleplugin.cpp +++ b/controls/com/vicr123/Contemporary/CoreStyles/contemporarystyleplugin.cpp @@ -2,11 +2,14 @@ #include "contemporarystyle.h" -ContemporaryStylePlugin::ContemporaryStylePlugin(QObject* parent) { +extern void qml_register_types_com_vicr123_Contemporary_CoreStyles(); +ContemporaryStylePlugin::ContemporaryStylePlugin(QObject* parent) { + volatile auto registration = &qml_register_types_com_vicr123_Contemporary_CoreStyles; + Q_UNUSED(registration); } void ContemporaryStylePlugin::initializeEngine(QQmlEngine* engine, const char* uri) { QQmlEngineExtensionPlugin::initializeEngine(engine, uri); qmlRegisterUncreatableType("Contemporary", 1, 0, "Contemporary", "Contemporary is an attached property"); -} \ No newline at end of file +} diff --git a/controls/com/vicr123/Contemporary/CoreStyles/contemporarystyleplugin.h b/controls/com/vicr123/Contemporary/CoreStyles/contemporarystyleplugin.h index def6fdf..0fcdaf2 100644 --- a/controls/com/vicr123/Contemporary/CoreStyles/contemporarystyleplugin.h +++ b/controls/com/vicr123/Contemporary/CoreStyles/contemporarystyleplugin.h @@ -3,13 +3,12 @@ #include -class ContemporaryStylePlugin : public QQmlEngineExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID QQmlEngineExtensionInterface_iid FILE "contemporarystyle.json") +class Q_DECL_EXPORT ContemporaryStylePlugin : public QQmlEngineExtensionPlugin { + Q_OBJECT + Q_PLUGIN_METADATA(IID QQmlEngineExtensionInterface_iid FILE "contemporarystyle.json") public: - explicit ContemporaryStylePlugin(QObject *parent = nullptr); + explicit ContemporaryStylePlugin(QObject* parent = nullptr); void initializeEngine(QQmlEngine* engine, const char* uri) override; }; diff --git a/controls/com/vicr123/Contemporary/impl/contemporaryimplstyleplugin.cpp b/controls/com/vicr123/Contemporary/impl/contemporaryimplstyleplugin.cpp index 1db1be4..812b694 100644 --- a/controls/com/vicr123/Contemporary/impl/contemporaryimplstyleplugin.cpp +++ b/controls/com/vicr123/Contemporary/impl/contemporaryimplstyleplugin.cpp @@ -2,8 +2,11 @@ #include "contemporaryapplication.h" -ContemporaryImplStylePlugin::ContemporaryImplStylePlugin(QObject* parent) { +extern void qml_register_types_com_vicr123_Contemporary_impl(); +ContemporaryImplStylePlugin::ContemporaryImplStylePlugin(QObject* parent) { + volatile auto registration = &qml_register_types_com_vicr123_Contemporary_impl; + Q_UNUSED(registration); } void ContemporaryImplStylePlugin::initializeEngine(QQmlEngine* engine, const char* uri) { diff --git a/controls/com/vicr123/Contemporary/impl/contemporaryimplstyleplugin.h b/controls/com/vicr123/Contemporary/impl/contemporaryimplstyleplugin.h index 693264e..08f598d 100644 --- a/controls/com/vicr123/Contemporary/impl/contemporaryimplstyleplugin.h +++ b/controls/com/vicr123/Contemporary/impl/contemporaryimplstyleplugin.h @@ -3,15 +3,14 @@ #include -class ContemporaryImplStylePlugin : public QQmlEngineExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID QQmlEngineExtensionInterface_iid FILE "contemporaryimplstyle.json") +class Q_DECL_EXPORT ContemporaryImplStylePlugin : public QQmlEngineExtensionPlugin { + Q_OBJECT + Q_PLUGIN_METADATA(IID QQmlEngineExtensionInterface_iid FILE "contemporaryimplstyle.json") public: - explicit ContemporaryImplStylePlugin(QObject *parent = nullptr); + explicit ContemporaryImplStylePlugin(QObject* parent = nullptr); - void initializeEngine(QQmlEngine* engine, const char* uri) override; + void initializeEngine(QQmlEngine* engine, const char* uri) override; }; #endif // CONTEMPORARYSTYLEPLUGIN_H