From 3fe8ef4c1c430eef69a43a9561ba300a06aeca21 Mon Sep 17 00:00:00 2001 From: Silent Date: Thu, 1 Aug 2019 19:52:28 +0200 Subject: [PATCH] Make alert messages application modal and not window modal, so assertions cannot be interrupted by terminating the application --- Source/Core/DolphinQt/Main.cpp | 2 +- Source/Core/DolphinQt/QtUtils/ModalMessageBox.cpp | 4 ++-- Source/Core/DolphinQt/QtUtils/ModalMessageBox.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Core/DolphinQt/Main.cpp b/Source/Core/DolphinQt/Main.cpp index ebbf53dd9e..e04832081c 100644 --- a/Source/Core/DolphinQt/Main.cpp +++ b/Source/Core/DolphinQt/Main.cpp @@ -39,7 +39,7 @@ static bool QtMsgAlertHandler(const char* caption, const char* text, bool yes_no Common::MsgType style) { std::optional r = RunOnObject(QApplication::instance(), [&] { - ModalMessageBox message_box(QApplication::activeWindow()); + ModalMessageBox message_box(QApplication::activeWindow(), Qt::ApplicationModal); message_box.setWindowTitle(QString::fromUtf8(caption)); message_box.setText(QString::fromUtf8(text)); diff --git a/Source/Core/DolphinQt/QtUtils/ModalMessageBox.cpp b/Source/Core/DolphinQt/QtUtils/ModalMessageBox.cpp index a6b06bdf09..752cfb3af7 100644 --- a/Source/Core/DolphinQt/QtUtils/ModalMessageBox.cpp +++ b/Source/Core/DolphinQt/QtUtils/ModalMessageBox.cpp @@ -6,10 +6,10 @@ #include -ModalMessageBox::ModalMessageBox(QWidget* parent) +ModalMessageBox::ModalMessageBox(QWidget* parent, Qt::WindowModality modality) : QMessageBox(parent != nullptr ? parent->window() : nullptr) { - setWindowModality(Qt::WindowModal); + setWindowModality(modality); setWindowFlags(Qt::Sheet | Qt::WindowTitleHint | Qt::CustomizeWindowHint); // No parent is still preferable to showing a hidden parent here. diff --git a/Source/Core/DolphinQt/QtUtils/ModalMessageBox.h b/Source/Core/DolphinQt/QtUtils/ModalMessageBox.h index 5eb3c597a3..14a7838968 100644 --- a/Source/Core/DolphinQt/QtUtils/ModalMessageBox.h +++ b/Source/Core/DolphinQt/QtUtils/ModalMessageBox.h @@ -10,7 +10,7 @@ class ModalMessageBox : public QMessageBox { public: - explicit ModalMessageBox(QWidget* parent); + explicit ModalMessageBox(QWidget* parent, Qt::WindowModality modality = Qt::WindowModal); static int critical(QWidget* parent, const QString& title, const QString& text, StandardButtons buttons = Ok, StandardButton default_button = NoButton);