Skip to content

Commit

Permalink
Don't optimise out QML registration function
Browse files Browse the repository at this point in the history
  • Loading branch information
vicr123 committed Apr 2, 2024
1 parent b8e63ed commit b3980dd
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<ContemporaryStyle>("Contemporary", 1, 0, "Contemporary", "Contemporary is an attached property");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@

#include <QQmlEngineExtensionPlugin>

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;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@

#include <QQmlEngineExtensionPlugin>

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

0 comments on commit b3980dd

Please sign in to comment.