Provide a parent HWND to assert messageboxes (assert no longer appears below..)

This commit is contained in:
Henrik Rydgård 2025-03-29 07:57:09 +01:00
parent 6aef6e2926
commit c906cee1ed
3 changed files with 12 additions and 1 deletions

View file

@ -31,6 +31,7 @@
#include <android/log.h>
#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<std::mutex> 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:

View file

@ -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.

View file

@ -861,6 +861,7 @@ namespace MainWindow
if (g_darkModeSupported) {
SendMessageW(hWnd, WM_THEMECHANGED, 0, 0);
}
SetAssertDialogParent(hWnd);
break;
case WM_USER_RUN_CALLBACK: