diff --git a/Common/Log.cpp b/Common/Log.cpp index f2bba89c76..c99666ed76 100644 --- a/Common/Log.cpp +++ b/Common/Log.cpp @@ -31,6 +31,7 @@ #include #elif PPSSPP_PLATFORM(WINDOWS) #include "CommonWindows.h" +static HWND g_dialogParent; #endif #define LOG_BUF_SIZE 2048 @@ -44,6 +45,14 @@ static bool g_exitOnAssert; static AssertNoCallbackFunc g_assertCancelCallback = 0; static void *g_assertCancelCallbackUserData = 0; + + +void SetAssertDialogParent(void *handle) { +#if PPSSPP_PLATFORM(WINDOWS) +g_dialogParent = (HWND)handle; +#endif +} + void SetExtraAssertInfo(const char *info) { std::lock_guard guard(g_extraAssertInfoMutex); g_extraAssertInfo = info ? info : "menu"; @@ -106,7 +115,7 @@ bool HandleAssert(const char *function, const char *file, int line, const char * OutputDebugStringA(formatted); printf("%s\n", formatted); std::wstring wcaption = ConvertUTF8ToWString(std::string(caption) + " " + (threadName ? threadName : "(unknown thread)")); - switch (MessageBox(0, ConvertUTF8ToWString(text).c_str(), wcaption.c_str(), msgBoxStyle)) { + switch (MessageBox(g_dialogParent, ConvertUTF8ToWString(text).c_str(), wcaption.c_str(), msgBoxStyle)) { case IDYES: return true; case IDNO: diff --git a/Common/Log.h b/Common/Log.h index 6e51c9e111..bb4866870a 100644 --- a/Common/Log.h +++ b/Common/Log.h @@ -138,6 +138,7 @@ typedef void (*AssertNoCallbackFunc)(const char *message, void *userdata); void SetAssertCancelCallback(AssertNoCallbackFunc callback, void *userdata); void SetCleanExitOnAssert(); void BreakIntoPSPDebugger(const char *reason = "(userbreak)"); +void SetAssertDialogParent(void *handle); // HWND on windows. Ignored on other platforms. #if defined(__ANDROID__) // Tricky macro to get the basename, that also works if *built* on Win32. diff --git a/Windows/MainWindow.cpp b/Windows/MainWindow.cpp index 9f01bfaf2d..2b0c00a90c 100644 --- a/Windows/MainWindow.cpp +++ b/Windows/MainWindow.cpp @@ -861,6 +861,7 @@ namespace MainWindow if (g_darkModeSupported) { SendMessageW(hWnd, WM_THEMECHANGED, 0, 0); } + SetAssertDialogParent(hWnd); break; case WM_USER_RUN_CALLBACK: