mirror of https://github.com/PCSX2/pcsx2.git
Qt: Add QtHost::RunOnUIThread()
This commit is contained in:
parent
0efe03e726
commit
821e15f1ee
|
@ -696,6 +696,11 @@ void MainWindow::reportError(const QString& title, const QString& message)
|
|||
QMessageBox::critical(this, title, message);
|
||||
}
|
||||
|
||||
void MainWindow::runOnUIThread(const std::function<void()>& func)
|
||||
{
|
||||
func();
|
||||
}
|
||||
|
||||
bool MainWindow::requestShutdown(bool allow_confirm /* = true */, bool allow_save_to_state /* = true */, bool block_until_done /* = false */)
|
||||
{
|
||||
if (!VMManager::HasValidVM())
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include <QtWidgets/QLabel>
|
||||
#include <QtWidgets/QMainWindow>
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
|
||||
#include "Settings/ControllerSettingsDialog.h"
|
||||
|
@ -55,6 +56,7 @@ public Q_SLOTS:
|
|||
void refreshGameList(bool invalidate_cache);
|
||||
void invalidateSaveStateCache();
|
||||
void reportError(const QString& title, const QString& message);
|
||||
void runOnUIThread(const std::function<void()>& func);
|
||||
bool requestShutdown(bool allow_confirm = true, bool allow_save_to_state = true, bool block_until_done = false);
|
||||
void requestExit();
|
||||
|
||||
|
|
|
@ -300,6 +300,14 @@ void QtHost::QueueSettingsSave()
|
|||
s_settings_save_timer->start(SETTINGS_SAVE_DELAY);
|
||||
}
|
||||
|
||||
void QtHost::RunOnUIThread(const std::function<void()>& func, bool block /*= false*/)
|
||||
{
|
||||
// main window always exists, so it's fine to attach it to that.
|
||||
QMetaObject::invokeMethod(g_main_window, "runOnUIThread",
|
||||
block ? Qt::BlockingQueuedConnection : Qt::QueuedConnection,
|
||||
Q_ARG(const std::function<void()>&, func));
|
||||
}
|
||||
|
||||
std::optional<std::vector<u8>> Host::ReadResourceFile(const char* filename)
|
||||
{
|
||||
const std::string path(Path::CombineStdString(EmuFolders::Resources, filename));
|
||||
|
|
|
@ -42,6 +42,9 @@ namespace QtHost
|
|||
void UpdateFolders();
|
||||
void UpdateLogging();
|
||||
|
||||
/// Executes a function on the UI thread.
|
||||
void RunOnUIThread(const std::function<void()>& func, bool block = false);
|
||||
|
||||
/// Thread-safe settings access.
|
||||
SettingsInterface* GetBaseSettingsInterface();
|
||||
std::string GetBaseStringSettingValue(const char* section, const char* key, const char* default_value = "");
|
||||
|
|
Loading…
Reference in New Issue