From 8dc52eae59af180f3904ce0c7f2f149d0cfce5c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anthony=20L=C3=A9onard?= <anthony.leonard@savoirfairelinux.com> Date: Tue, 19 Sep 2017 15:47:12 -0400 Subject: [PATCH] ensure daemon is running before Lrc construction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On non-DBus platforms, where the daemon is not running in its own process, LRC is responsible for its initalization. This patch ensures it is done in Lrc class constructor before any attempt to grab data from it (like accounts). It then makes it possible to use the new models in Win32 and macOS clients. Change-Id: Ib587bf86e17ae7f19766ac5bb5d8c91aa05d335c Reviewed-by: Sébastien Blin <sebastien.blin@savoirfairelinux.com> --- src/lrc.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lrc.cpp b/src/lrc.cpp index eb512d06..3cc4ea7e 100644 --- a/src/lrc.cpp +++ b/src/lrc.cpp @@ -22,6 +22,7 @@ #include "api/newaccountmodel.h" #include "database.h" #include "callbackshandler.h" +#include "dbus/instancemanager.h" namespace lrc { @@ -41,8 +42,11 @@ public: }; Lrc::Lrc() -: lrcPipmpl_(std::make_unique<LrcPimpl>(*this)) { + // Ensure Daemon is running/loaded (especially on non-DBus platforms) + // before instantiating LRC and its members + InstanceManager::instance(); + lrcPipmpl_ = std::make_unique<LrcPimpl>(*this); } Lrc::~Lrc() -- GitLab