From 2668e0fcf29f7c452320f4c53ebd599498a3498b Mon Sep 17 00:00:00 2001 From: Erik Prabowo Kamal Date: Sat, 31 Aug 2019 18:14:46 +0800 Subject: 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. --- main.cxx | 8 ++++++-- 1 file 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("id.co.darapsa.kelakon.user", 0, 1, "User", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject* { + auto typeId = qmlRegisterSingletonType("id.co.darapsa.kelakon.user", 0, 1, "User", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject* { Q_UNUSED(engine) Q_UNUSED(scriptEngine) return new User{}; }); - qmlRegisterSingletonType("id.co.darapsa.kelakon.rtclient", 0, 1, "RTClient", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject* { + auto user = engine.singletonInstance(typeId); + Q_UNUSED(user) + typeId = qmlRegisterSingletonType("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(typeId); + Q_UNUSED(controller) engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); return app.exec(); -- cgit v1.2.3 From a52ce8bdc2ebabc1f883f4573025e7526d96b80f Mon Sep 17 00:00:00 2001 From: Erik Prabowo Kamal Date: Sat, 31 Aug 2019 18:15:48 +0800 Subject: The server URL setting is done at the rtclient's initialisation --- librtclient | 2 +- worker.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/librtclient b/librtclient index b4ed476..f4f2546 160000 --- a/librtclient +++ b/librtclient @@ -1 +1 @@ -Subproject commit b4ed4766047759c875aa42cc35b52ccecbfcc6ef +Subproject commit f4f2546bad4ad3bffb2ffe8f561445c81dd2fda5 diff --git a/worker.cxx b/worker.cxx index 19ae358..071983e 100644 --- a/worker.cxx +++ b/worker.cxx @@ -4,7 +4,7 @@ Worker::Worker(QObject* parent) : QObject{parent} { - rtclient_init(); + rtclient_init("https://darapsa.co.id/rt"); } void Worker::logIn(QString const& name, QString const& password) -- cgit v1.2.3