From bf5f2b81798c48c578da525c7bc70bca7be01b1d Mon Sep 17 00:00:00 2001 From: Yuri Gorshenin Date: Fri, 22 Jan 2016 16:08:32 +0300 Subject: [PATCH] [platform][linux] Fixed Platform::RunOnGuiThread(). --- platform/platform_linux.cpp | 12 ------------ platform/platform_qt.cpp | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/platform/platform_linux.cpp b/platform/platform_linux.cpp index d41a1bc026..2e54562c8d 100644 --- a/platform/platform_linux.cpp +++ b/platform/platform_linux.cpp @@ -135,18 +135,6 @@ string Platform::UniqueClientId() const return "n0dbus0n0lsb00000000000000000000"; } -void Platform::RunOnGuiThread(TFunctor const & fn) -{ - /// @todo - fn(); -} - -void Platform::RunAsync(TFunctor const & fn, Priority p) -{ - /// @todo - fn(); -} - Platform::EConnectionType Platform::ConnectionStatus() { int socketFd = socket(AF_INET, SOCK_STREAM, 0); diff --git a/platform/platform_qt.cpp b/platform/platform_qt.cpp index b5e5edc937..da784a4bf1 100644 --- a/platform/platform_qt.cpp +++ b/platform/platform_qt.cpp @@ -8,9 +8,11 @@ #include "base/logging.hpp" #include "std/algorithm.hpp" +#include "std/future.hpp" #include "std/regex.hpp" #include "std/target_os.hpp" +#include #include #include #include @@ -80,6 +82,21 @@ void Platform::SetupMeasurementSystem() const Settings::Set("Units", u); } +#if defined(OMIM_OS_LINUX) +void Platform::RunOnGuiThread(TFunctor const & fn) +{ + // Following hack is used to post on main message loop |fn| when + // |source| is destroyed (at the exit of the code block). + QObject source; + QObject::connect(&source, &QObject::destroyed, QCoreApplication::instance(), fn); +} + +void Platform::RunAsync(TFunctor const & fn, Priority p) +{ + async(fn); +} +#endif // defined(OMIM_OS_LINUX) + extern Platform & GetPlatform() { static Platform platform;