CommonHostInterface: Make RunLater()/ApplySettings() virtual

This commit is contained in:
Connor McLaughlin
2021-01-30 15:52:36 +10:00
parent ec60fa3c9d
commit 41be96ef93
5 changed files with 37 additions and 12 deletions

View File

@ -306,6 +306,11 @@ void QtHostInterface::applySettings(bool display_osd_messages /* = false */)
return;
}
ApplySettings(display_osd_messages);
}
void QtHostInterface::ApplySettings(bool display_osd_messages)
{
Settings old_settings(std::move(g_settings));
{
std::lock_guard<std::recursive_mutex> guard(m_settings_mutex);
@ -1168,7 +1173,7 @@ void QtHostInterface::executeOnEmulationThread(std::function<void()> callback, b
}
QMetaObject::invokeMethod(this, "executeOnEmulationThread", Qt::QueuedConnection,
Q_ARG(std::function<void()>, callback), Q_ARG(bool, wait));
Q_ARG(std::function<void()>, std::move(callback)), Q_ARG(bool, wait));
if (wait)
{
// don't deadlock
@ -1178,6 +1183,12 @@ void QtHostInterface::executeOnEmulationThread(std::function<void()> callback, b
}
}
void QtHostInterface::RunLater(std::function<void()> func)
{
QMetaObject::invokeMethod(this, "executeOnEmulationThread", Qt::QueuedConnection,
Q_ARG(std::function<void()>, std::move(func)), Q_ARG(bool, false));
}
void QtHostInterface::loadState(const QString& filename)
{
if (!isOnWorkerThread())

View File

@ -2,6 +2,7 @@
#include "common/event.h"
#include "core/host_interface.h"
#include "core/system.h"
#include "qtutils.h"
#include "frontend-common/common_host_interface.h"
#include <QtCore/QByteArray>
#include <QtCore/QObject>
@ -205,10 +206,12 @@ protected:
void OnSystemStateSaved(bool global, s32 slot) override;
void LoadSettings() override;
void ApplySettings(bool display_osd_messages) override;
void SetDefaultSettings(SettingsInterface& si) override;
void UpdateInputMap() override;
void SetMouseMode(bool relative, bool hide_cursor) override;
void RunLater(std::function<void()> func) override;
private:
enum : u32