diff --git a/Common/Log.cpp b/Common/Log.cpp index 988e51f439..31c614a9aa 100644 --- a/Common/Log.cpp +++ b/Common/Log.cpp @@ -37,9 +37,10 @@ static bool hitAnyAsserts = false; -std::mutex g_extraAssertInfoMutex; -std::string g_extraAssertInfo = "menu"; -double g_assertInfoTime = 0.0; +static std::mutex g_extraAssertInfoMutex; +static std::string g_extraAssertInfo = "menu"; +static double g_assertInfoTime = 0.0; +static bool g_exitOnAssert; void SetExtraAssertInfo(const char *info) { std::lock_guard guard(g_extraAssertInfoMutex); @@ -47,6 +48,10 @@ void SetExtraAssertInfo(const char *info) { g_assertInfoTime = time_now_d(); } +void SetCleanExitOnAssert() { + g_exitOnAssert = true; +} + bool HandleAssert(const char *function, const char *file, int line, const char *expression, const char* format, ...) { // Read message and write it to the log char text[LOG_BUF_SIZE]; @@ -78,8 +83,13 @@ bool HandleAssert(const char *function, const char *file, int line, const char * std::wstring wtext = ConvertUTF8ToWString(formatted) + L"\n\nTry to continue?"; std::wstring wcaption = ConvertUTF8ToWString(std::string(caption) + " " + GetCurrentThreadName()); OutputDebugString(wtext.c_str()); + printf("%s\n", formatted); if (IDYES != MessageBox(0, wtext.c_str(), wcaption.c_str(), msgBoxStyle)) { - return false; + if (g_exitOnAssert) { + // Hard exit. + ExitProcess(1); + return false; + } } else { return true; } diff --git a/Common/Log.h b/Common/Log.h index 91b834b7fa..eaa20ac7c0 100644 --- a/Common/Log.h +++ b/Common/Log.h @@ -121,6 +121,7 @@ __attribute__((format(printf, 5, 6))) bool HitAnyAsserts(); void ResetHitAnyAsserts(); void SetExtraAssertInfo(const char *info); +void SetCleanExitOnAssert(); #if defined(__ANDROID__) // Tricky macro to get the basename, that also works if *built* on Win32. diff --git a/headless/Headless.cpp b/headless/Headless.cpp index a396c591a0..6ce62ffa81 100644 --- a/headless/Headless.cpp +++ b/headless/Headless.cpp @@ -319,6 +319,7 @@ int main(int argc, const char* argv[]) { PROFILE_INIT(); #if PPSSPP_PLATFORM(WINDOWS) + SetCleanExitOnAssert(); timeBeginPeriod(1); #else // Ignore sigpipe.