mirror of
https://github.com/stenzek/duckstation.git
synced 2026-02-08 23:34:32 +00:00
Host: Remove blocking ConfirmMessage()
No longer needed.
This commit is contained in:
@@ -4242,7 +4242,9 @@ void FullscreenUI::BackgroundProgressCallback::ModalError(const std::string_view
|
||||
|
||||
bool FullscreenUI::BackgroundProgressCallback::ModalConfirmation(const std::string_view message)
|
||||
{
|
||||
return Host::ConfirmMessage("Confirm", message);
|
||||
// Not used.
|
||||
INFO_LOG(message);
|
||||
return true;
|
||||
}
|
||||
|
||||
void FullscreenUI::BackgroundProgressCallback::ModalInformation(const std::string_view message)
|
||||
@@ -4668,8 +4670,9 @@ void FullscreenUI::LoadingScreenProgressCallback::ModalError(const std::string_v
|
||||
|
||||
bool FullscreenUI::LoadingScreenProgressCallback::ModalConfirmation(const std::string_view message)
|
||||
{
|
||||
// Not used.
|
||||
INFO_LOG(message);
|
||||
return Host::ConfirmMessage("Confirm", message);
|
||||
return true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -1438,28 +1438,6 @@ std::string Host::FormatNumber(NumberFormatType type, double value)
|
||||
return fmt::format("{}", value);
|
||||
}
|
||||
|
||||
bool Host::ConfirmMessage(std::string_view title, std::string_view message)
|
||||
{
|
||||
const SmallString title_copy(title);
|
||||
const SmallString message_copy(message);
|
||||
|
||||
static constexpr SDL_MessageBoxButtonData bd[2] = {
|
||||
{SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 1, "Yes"},
|
||||
{SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, 2, "No"},
|
||||
};
|
||||
const SDL_MessageBoxData md = {SDL_MESSAGEBOX_INFORMATION,
|
||||
nullptr,
|
||||
title_copy.c_str(),
|
||||
message_copy.c_str(),
|
||||
static_cast<int>(std::size(bd)),
|
||||
bd,
|
||||
nullptr};
|
||||
|
||||
int buttonid = -1;
|
||||
SDL_ShowMessageBox(&md, &buttonid);
|
||||
return (buttonid == 1);
|
||||
}
|
||||
|
||||
void Host::ConfirmMessageAsync(std::string_view title, std::string_view message, ConfirmMessageAsyncCallback callback,
|
||||
std::string_view yes_text /* = std::string_view() */,
|
||||
std::string_view no_text /* = std::string_view() */)
|
||||
|
||||
@@ -216,13 +216,6 @@ void MainWindow::reportError(const QString& title, const QString& message)
|
||||
QtUtils::AsyncMessageBox(this, QMessageBox::Critical, title, message);
|
||||
}
|
||||
|
||||
bool MainWindow::confirmMessage(const QString& title, const QString& message)
|
||||
{
|
||||
SystemLock lock(pauseAndLockSystem());
|
||||
|
||||
return (QtUtils::MessageBoxQuestion(this, title, message) == QMessageBox::Yes);
|
||||
}
|
||||
|
||||
void MainWindow::onStatusMessage(const QString& message)
|
||||
{
|
||||
m_ui.statusBar->showMessage(message);
|
||||
@@ -2560,7 +2553,6 @@ void MainWindow::connectSignals()
|
||||
connect(g_emu_thread, &EmuThread::settingsResetToDefault, this, &MainWindow::onSettingsResetToDefault,
|
||||
Qt::QueuedConnection);
|
||||
connect(g_emu_thread, &EmuThread::errorReported, this, &MainWindow::reportError);
|
||||
connect(g_emu_thread, &EmuThread::messageConfirmed, this, &MainWindow::confirmMessage, Qt::BlockingQueuedConnection);
|
||||
connect(g_emu_thread, &EmuThread::statusMessage, this, &MainWindow::onStatusMessage);
|
||||
connect(g_emu_thread, &EmuThread::onAcquireRenderWindowRequested, this, &MainWindow::acquireRenderWindow,
|
||||
Qt::BlockingQueuedConnection);
|
||||
|
||||
@@ -138,7 +138,6 @@ public:
|
||||
void* getNativeWindowId();
|
||||
|
||||
void reportError(const QString& title, const QString& message);
|
||||
bool confirmMessage(const QString& title, const QString& message);
|
||||
void onStatusMessage(const QString& message);
|
||||
|
||||
void onRAIntegrationMenuChanged();
|
||||
|
||||
@@ -2102,14 +2102,6 @@ void Host::ReportErrorAsync(std::string_view title, std::string_view message)
|
||||
message.empty() ? QString() : QString::fromUtf8(message.data(), message.size()));
|
||||
}
|
||||
|
||||
bool Host::ConfirmMessage(std::string_view title, std::string_view message)
|
||||
{
|
||||
auto lock = g_emu_thread->pauseAndLockSystem();
|
||||
|
||||
return emit g_emu_thread->messageConfirmed(QString::fromUtf8(title.data(), title.size()),
|
||||
QString::fromUtf8(message.data(), message.size()));
|
||||
}
|
||||
|
||||
void Host::ConfirmMessageAsync(std::string_view title, std::string_view message, ConfirmMessageAsyncCallback callback,
|
||||
std::string_view yes_text, std::string_view no_text)
|
||||
{
|
||||
|
||||
@@ -129,7 +129,6 @@ public:
|
||||
|
||||
Q_SIGNALS:
|
||||
void errorReported(const QString& title, const QString& message);
|
||||
bool messageConfirmed(const QString& title, const QString& message);
|
||||
void statusMessage(const QString& message);
|
||||
void debuggerMessageReported(const QString& message);
|
||||
void settingsResetToDefault(bool system, bool controller);
|
||||
|
||||
@@ -161,16 +161,6 @@ void Host::ReportErrorAsync(std::string_view title, std::string_view message)
|
||||
ERROR_LOG("ReportErrorAsync: {}", message);
|
||||
}
|
||||
|
||||
bool Host::ConfirmMessage(std::string_view title, std::string_view message)
|
||||
{
|
||||
if (!title.empty() && !message.empty())
|
||||
ERROR_LOG("ConfirmMessage: {}: {}", title, message);
|
||||
else if (!message.empty())
|
||||
ERROR_LOG("ConfirmMessage: {}", message);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Host::ConfirmMessageAsync(std::string_view title, std::string_view message, ConfirmMessageAsyncCallback callback,
|
||||
std::string_view yes_text, std::string_view no_text)
|
||||
{
|
||||
|
||||
@@ -38,9 +38,6 @@ void ReportFatalError(std::string_view title, std::string_view message);
|
||||
/// Displays an asynchronous error on the UI thread, i.e. doesn't block the caller.
|
||||
void ReportErrorAsync(std::string_view title, std::string_view message);
|
||||
|
||||
/// Displays a synchronous confirmation on the UI thread, i.e. blocks the caller.
|
||||
bool ConfirmMessage(std::string_view title, std::string_view message);
|
||||
|
||||
/// Displays an asynchronous confirmation on the UI thread, but does not block the caller.
|
||||
/// The callback may be executed on a different thread. Use RunOnCPUThread() in the callback to ensure safety.
|
||||
using ConfirmMessageAsyncCallback = std::function<void(bool)>;
|
||||
|
||||
Reference in New Issue
Block a user