From d83bc54973391b217991ee091fb8b0c2ab8af99c Mon Sep 17 00:00:00 2001
From: Nicolas Jager <nicolas.jager@savoirfairelinux.com>
Date: Fri, 16 Sep 2016 12:07:31 -0400
Subject: [PATCH] fix : dispatcher locked

Change-Id: I8a6c2cf99e70c682420699fa6a0b66e996f0eb36
Tuleap: #1046
---
 RingD.cpp | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/RingD.cpp b/RingD.cpp
index ccd7f00..03e0b25 100644
--- a/RingD.cpp
+++ b/RingD.cpp
@@ -37,12 +37,6 @@ using namespace RingClientUWP;
 using namespace RingClientUWP::Utils;
 using namespace RingClientUWP::ViewModel;
 
-void
-debugOutputWrapper(const std::string& str)
-{
-    MSG_(str);
-}
-
 void
 RingClientUWP::RingD::reloadAccountList()
 {
@@ -178,6 +172,8 @@ RingClientUWP::RingD::startDaemon()
         using SharedCallback = std::shared_ptr<DRing::CallbackWrapperBase>;
         using namespace std::placeholders;
 
+        auto dispatcher = CoreApplication::MainView->CoreWindow->Dispatcher;
+
         std::map<std::string, SharedCallback> callHandlers = {
             // use IncomingCall only to register the call client sided, use StateChange to determine the impact on the UI
             DRing::exportable_callback<DRing::CallSignal::IncomingCall>([this](
@@ -266,6 +262,13 @@ RingClientUWP::RingD::startDaemon()
                     reloadAccountList();
                 }));
             }),
+            DRing::exportable_callback<DRing::Debug::MessageSend>([&](const std::string& toto)
+            {
+                dispatcher->RunAsync(CoreDispatcherPriority::Normal,
+                ref new DispatchedHandler([=]() {
+                    RingDebug::instance->print(toto);
+                }));
+            })
             /* to remove from daemon API, this callback is never used */
             //DRing::exportable_callback<DRing::CallSignal::NewCallCreated>([&](
             //            const std::string& accountId,
@@ -276,11 +279,6 @@ RingClientUWP::RingD::startDaemon()
 
         registerCallHandlers(callHandlers);
 
-        std::map<std::string, SharedCallback> dringDebugOutHandler;
-        dringDebugOutHandler.insert(DRing::exportable_callback<DRing::Debug::MessageSend>
-                                    (std::bind(&debugOutputWrapper, _1)));
-        registerCallHandlers(dringDebugOutHandler);
-
         std::map<std::string, SharedCallback> getAppPathHandler =
         {
             DRing::exportable_callback<DRing::ConfigurationSignal::GetAppDataPath>
-- 
GitLab