summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id>2019-09-14 06:51:44 +0800
committerꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id>2019-09-14 06:51:44 +0800
commit58be31e2d8098c5ce8b8406a9e96f88dcc0dcf9c (patch)
tree739da8c1662163f6fb3e42d51c3dbcafef8d9ed7
parent4ceea1de7eccc623fe33d823ba4446f6323d5248 (diff)
No need for task list to be instantiated as a singleton
-rw-r--r--controller.cxx3
-rw-r--r--controller.hxx1
-rw-r--r--main.cxx8
3 files changed, 3 insertions, 9 deletions
diff --git a/controller.cxx b/controller.cxx
index 42b1ece..6be4f40 100644
--- a/controller.cxx
+++ b/controller.cxx
@@ -24,7 +24,7 @@ Controller::Controller(QObject* parent) : QObject{parent}
auto user = engine->singletonInstance<User*>(User::typeId);
connect(worker, SIGNAL(logged(rt_user*)), user, SLOT(update(rt_user*)));
- auto taskList = engine->singletonInstance<TaskList*>(TaskList::typeId);
+ taskList = new TaskList;
engine->rootContext()->setContextProperty("taskList", taskList);
connect(worker, SIGNAL(foundTasks(rt_ticketlist*))
, taskList, SLOT(addTasks(rt_ticketlist*)));
@@ -36,4 +36,5 @@ Controller::~Controller()
{
thread.quit();
thread.wait();
+ delete taskList;
}
diff --git a/controller.hxx b/controller.hxx
index d98a735..5d4ef89 100644
--- a/controller.hxx
+++ b/controller.hxx
@@ -13,6 +13,7 @@ class Controller : public QObject
private:
QThread thread;
+ class TaskList* taskList;
};
#endif // CONTROLLER_HXX
diff --git a/main.cxx b/main.cxx
index ff184e7..f3a9cb9 100644
--- a/main.cxx
+++ b/main.cxx
@@ -18,14 +18,6 @@ int main(int argc, char* argv[])
return new User;
});
- TaskList::typeId = qmlRegisterSingletonType<User>("KelakonUser", 0, 1, "TaskList"
- , [](QQmlEngine *engine,
- QJSEngine *scriptEngine) -> QObject* {
- Q_UNUSED(engine)
- Q_UNUSED(scriptEngine)
- return new TaskList;
- });
-
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
Controller controller{&engine};