shithub: ft²

Download patch

ref: 59a927b54268413577279792d93db470099d5473
parent: e81e24ffbc9efdd4a146b38329cf85c11ca36386
author: Olav Sørensen <olav.sorensen@live.no>
date: Tue Apr 9 15:31:25 EDT 2024

showErrorMsgBox() fix for Windows XP

--- a/src/ft2_video.c
+++ b/src/ft2_video.c
@@ -255,16 +255,20 @@
 
 void showErrorMsgBox(const char *fmt, ...)
 {
-	char strBuf[256];
+	char strBuf[512+1];
 	va_list args;
 
 	// format the text string
 	va_start(args, fmt);
-	vsnprintf(strBuf, sizeof (strBuf), fmt, args);
+	vsnprintf(strBuf, sizeof (strBuf)-1, fmt, args);
 	va_end(args);
 
-	// window can be NULL here, no problem...
-	SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", strBuf, video.window);
+	// SDL message boxes can be very buggy on Windows XP, use MessageBoxA() instead
+#ifdef _WIN32
+	MessageBoxA(NULL, strBuf, "Error", MB_OK | MB_ICONERROR);
+#else
+	SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", strBuf, NULL);
+#endif
 }
 
 static void updateRenderSizeVars(void)