mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-26 23:10:38 +00:00
Make asserts work better in headless when running tests on Windows
This commit is contained in:
parent
5a38a359e9
commit
178147b20a
@ -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<std::mutex> 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;
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -319,6 +319,7 @@ int main(int argc, const char* argv[])
|
||||
{
|
||||
PROFILE_INIT();
|
||||
#if PPSSPP_PLATFORM(WINDOWS)
|
||||
SetCleanExitOnAssert();
|
||||
timeBeginPeriod(1);
|
||||
#else
|
||||
// Ignore sigpipe.
|
||||
|
Loading…
Reference in New Issue
Block a user