summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Prabowo Kamal <erik@darapsa.co.id>2019-08-31 18:14:46 +0800
committerErik Prabowo Kamal <erik@darapsa.co.id>2019-08-31 18:14:46 +0800
commit2668e0fcf29f7c452320f4c53ebd599498a3498b (patch)
tree0a7664253526fe679224d8dc1026b3c95dd4ad17
parentbc16081929011b89a02e57f0b087c99ddb9f4ce7 (diff)
Made sure the user and controller singletons are instantiated early
This is because when the controller is lazy loaded, somehow the worker failed to initialise librtclient with the server URL before libcurl gets to perform.
-rw-r--r--main.cxx8
1 files changed, 6 insertions, 2 deletions
diff --git a/main.cxx b/main.cxx
index a29e917..23ba4ac 100644
--- a/main.cxx
+++ b/main.cxx
@@ -9,16 +9,20 @@ int main(int argc, char* argv[])
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
- qmlRegisterSingletonType<User>("id.co.darapsa.kelakon.user", 0, 1, "User", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject* {
+ auto typeId = qmlRegisterSingletonType<User>("id.co.darapsa.kelakon.user", 0, 1, "User", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject* {
Q_UNUSED(engine)
Q_UNUSED(scriptEngine)
return new User{};
});
- qmlRegisterSingletonType<User>("id.co.darapsa.kelakon.rtclient", 0, 1, "RTClient", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject* {
+ auto user = engine.singletonInstance<User*>(typeId);
+ Q_UNUSED(user)
+ typeId = qmlRegisterSingletonType<User>("id.co.darapsa.kelakon.rtclient", 0, 1, "RTClient", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject* {
Q_UNUSED(engine)
Q_UNUSED(scriptEngine)
return new Controller{};
});
+ auto controller = engine.singletonInstance<Controller*>(typeId);
+ Q_UNUSED(controller)
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
return app.exec();