mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-12 23:48:58 +01:00
Merge pull request #10138 from Pokechu22/abort-on-panic-alert-fmt
Fix AbortOnPanicAlert with PanicAlertFmt
This commit is contained in:
commit
480cd35951
@ -106,20 +106,10 @@ std::string GetStringT(const char* string)
|
|||||||
return s_str_translator(string);
|
return s_str_translator(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is the first stop for gui alerts where the log is updated and the
|
static bool ShowMessageAlert(std::string_view text, bool yes_no, MsgType style)
|
||||||
// correct window is shown
|
|
||||||
bool MsgAlert(bool yes_no, MsgType style, const char* format, ...)
|
|
||||||
{
|
{
|
||||||
// Read message and write it to the log
|
|
||||||
const char* caption = GetCaption(style);
|
const char* caption = GetCaption(style);
|
||||||
char buffer[2048];
|
ERROR_LOG_FMT(MASTER_LOG, "{}: {}", caption, text);
|
||||||
|
|
||||||
va_list args;
|
|
||||||
va_start(args, format);
|
|
||||||
CharArrayFromFormatV(buffer, sizeof(buffer) - 1, s_str_translator(format).c_str(), args);
|
|
||||||
va_end(args);
|
|
||||||
|
|
||||||
ERROR_LOG_FMT(MASTER_LOG, "{}: {}", caption, buffer);
|
|
||||||
|
|
||||||
// Panic alerts.
|
// Panic alerts.
|
||||||
if (style == MsgType::Warning && s_abort_on_panic_alert)
|
if (style == MsgType::Warning && s_abort_on_panic_alert)
|
||||||
@ -131,26 +121,33 @@ bool MsgAlert(bool yes_no, MsgType style, const char* format, ...)
|
|||||||
if (s_msg_handler != nullptr &&
|
if (s_msg_handler != nullptr &&
|
||||||
(s_alert_enabled || style == MsgType::Question || style == MsgType::Critical))
|
(s_alert_enabled || style == MsgType::Question || style == MsgType::Critical))
|
||||||
{
|
{
|
||||||
return s_msg_handler(caption, buffer, yes_no, style);
|
return s_msg_handler(caption, text.data(), yes_no, style);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is the first stop for gui alerts where the log is updated and the
|
||||||
|
// correct window is shown, but only for legacy printf-style messages
|
||||||
|
bool MsgAlert(bool yes_no, MsgType style, const char* format, ...)
|
||||||
|
{
|
||||||
|
char buffer[2048];
|
||||||
|
|
||||||
|
va_list args;
|
||||||
|
va_start(args, format);
|
||||||
|
CharArrayFromFormatV(buffer, sizeof(buffer) - 1, s_str_translator(format).c_str(), args);
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
return ShowMessageAlert(buffer, yes_no, style);
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is the first stop for gui alerts where the log is updated and the
|
||||||
|
// correct window is shown, when using fmt
|
||||||
bool MsgAlertFmtImpl(bool yes_no, MsgType style, fmt::string_view format,
|
bool MsgAlertFmtImpl(bool yes_no, MsgType style, fmt::string_view format,
|
||||||
const fmt::format_args& args)
|
const fmt::format_args& args)
|
||||||
{
|
{
|
||||||
const char* caption = GetCaption(style);
|
|
||||||
const auto message = fmt::vformat(format, args);
|
const auto message = fmt::vformat(format, args);
|
||||||
ERROR_LOG_FMT(MASTER_LOG, "{}: {}", caption, message);
|
|
||||||
|
|
||||||
// Don't ignore questions, especially AskYesNo, PanicYesNo could be ignored
|
return ShowMessageAlert(message, yes_no, style);
|
||||||
if (s_msg_handler != nullptr &&
|
|
||||||
(s_alert_enabled || style == MsgType::Question || style == MsgType::Critical))
|
|
||||||
{
|
|
||||||
return s_msg_handler(caption, message.c_str(), yes_no, style);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
} // namespace Common
|
} // namespace Common
|
||||||
|
Loading…
x
Reference in New Issue
Block a user