summaryrefslogtreecommitdiff
path: root/Source/Core/Common/MsgHandler.cpp
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2021-08-30 22:43:21 +0200
committerGitHub <noreply@github.com>2021-08-30 22:43:21 +0200
commitd7109b149b243dce1720d8c51fbabebadde53456 (patch)
treec3c8f874c81e423b4789b1158a184330f4b9eb9c /Source/Core/Common/MsgHandler.cpp
parent16a903890ca527e2956bdc0acd97ae6d7e8c8300 (diff)
parente091c2e8173343c5ab8833a700bf4c6f4d15a5d2 (diff)
Merge pull request #10066 from leoetlino/abort-on-panic-alert-option
Add an option to abort when a panic alert occurs
Diffstat (limited to 'Source/Core/Common/MsgHandler.cpp')
-rw-r--r--Source/Core/Common/MsgHandler.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/Source/Core/Common/MsgHandler.cpp b/Source/Core/Common/MsgHandler.cpp
index fa7d246a9d..2cdccd59b7 100644
--- a/Source/Core/Common/MsgHandler.cpp
+++ b/Source/Core/Common/MsgHandler.cpp
@@ -4,6 +4,7 @@
#include "Common/MsgHandler.h"
#include <cstdarg>
+#include <cstdlib>
#include <string>
#ifdef _WIN32
@@ -51,6 +52,7 @@ std::string DefaultStringTranslator(const char* text)
MsgAlertHandler s_msg_handler = DefaultMsgHandler;
StringTranslator s_str_translator = DefaultStringTranslator;
bool s_alert_enabled = true;
+bool s_abort_on_panic_alert = false;
const char* GetCaption(MsgType style)
{
@@ -94,6 +96,11 @@ void SetEnableAlert(bool enable)
s_alert_enabled = enable;
}
+void SetAbortOnPanicAlert(bool should_abort)
+{
+ s_abort_on_panic_alert = should_abort;
+}
+
std::string GetStringT(const char* string)
{
return s_str_translator(string);
@@ -114,6 +121,12 @@ bool MsgAlert(bool yes_no, MsgType style, const char* format, ...)
ERROR_LOG_FMT(MASTER_LOG, "{}: {}", caption, buffer);
+ // Panic alerts.
+ if (style == MsgType::Warning && s_abort_on_panic_alert)
+ {
+ std::abort();
+ }
+
// Don't ignore questions, especially AskYesNo, PanicYesNo could be ignored
if (s_msg_handler != nullptr &&
(s_alert_enabled || style == MsgType::Question || style == MsgType::Critical))