Files
comaps/libs/platform/gui_thread_qt.cpp
Alexander Borsuk 76ffc99abd New cpp folder structure
Signed-off-by: Alexander Borsuk <me@alex.bio>
2025-08-14 20:52:04 +07:00

29 lines
821 B
C++

#include "platform/gui_thread.hpp"
#include <utility>
#include <QtCore/QCoreApplication>
namespace platform
{
base::TaskLoop::PushResult GuiThread::Push(Task && task)
{
// 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(), std::move(task));
return {true, base::TaskLoop::kNoId};
}
base::TaskLoop::PushResult GuiThread::Push(Task const & task)
{
// 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(), task);
return {true, base::TaskLoop::kNoId};
}
} // namespace platform