[platform][linux] Fixed Platform::RunOnGuiThread().

This commit is contained in:
Yuri Gorshenin 2016-01-22 16:08:32 +03:00 committed by Sergey Yershov
parent 4b02d33fbb
commit bf5f2b8179
2 changed files with 17 additions and 12 deletions

View file

@ -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);

View file

@ -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 <QtCore/QCoreApplication>
#include <QtCore/QDir>
#include <QtCore/QFileInfo>
#include <QtCore/QLocale>
@ -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;