Skip to content
Snippets Groups Projects
Commit 15a214e2 authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Use the reaper and process WM_CLOSE

One or both of these should fix weird GDI zombie issues.
parent e578754a
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #4214 passed
...@@ -157,7 +157,7 @@ static void ...@@ -157,7 +157,7 @@ static void
gdi_mouse_thread(void *data) gdi_mouse_thread(void *data)
{ {
SetThreadName("GDI Mouse"); SetThreadName("GDI Mouse");
while(wch != NULL) { while(wch != NULL && ciolib_reaper) {
if(mouse_wait()) if(mouse_wait())
gdi_add_key(CIO_KEY_MOUSE); gdi_add_key(CIO_KEY_MOUSE);
} }
...@@ -526,6 +526,7 @@ gdi_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { ...@@ -526,6 +526,7 @@ gdi_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
return gdi_handle_wm_size(wParam, lParam); return gdi_handle_wm_size(wParam, lParam);
//case WM_SIZING: //case WM_SIZING:
// return gdi_handle_wm_sizing(wParam, (RECT *)lParam); // return gdi_handle_wm_sizing(wParam, (RECT *)lParam);
case WM_CLOSE:
case WM_DESTROY: case WM_DESTROY:
PostQuitMessage(0); PostQuitMessage(0);
return 0; return 0;
...@@ -743,13 +744,12 @@ gdi_thread(void *arg) ...@@ -743,13 +744,12 @@ gdi_thread(void *arg)
init_success = true; init_success = true;
ReleaseSemaphore(init_sem, 1, NULL); ReleaseSemaphore(init_sem, 1, NULL);
while (GetMessage(&msg, NULL, 0, 0)) { while (GetMessage(&msg, NULL, 0, 0) && ciolib_reaper) {
if (!magic_message(msg)) { if (!magic_message(msg)) {
TranslateMessage(&msg); TranslateMessage(&msg);
DispatchMessage(&msg); DispatchMessage(&msg);
} }
} }
// This may not be necessary...
DestroyWindow(win); DestroyWindow(win);
UnregisterClassW(wc.lpszClassName, NULL); UnregisterClassW(wc.lpszClassName, NULL);
gdi_add_key(CIO_KEY_QUIT); gdi_add_key(CIO_KEY_QUIT);
...@@ -955,6 +955,12 @@ gdi_get_window_info(int *width, int *height, int *xpos, int *ypos) ...@@ -955,6 +955,12 @@ gdi_get_window_info(int *width, int *height, int *xpos, int *ypos)
return(1); return(1);
} }
void
gdi_reaper(void)
{
ciolib_reaper = 0;
}
int int
gdi_init(int mode) gdi_init(int mode)
{ {
...@@ -1000,6 +1006,7 @@ gdi_init(int mode) ...@@ -1000,6 +1006,7 @@ gdi_init(int mode)
else if (SetProcessDPIAware) { else if (SetProcessDPIAware) {
SetProcessDPIAware(); SetProcessDPIAware();
} }
atexit(gdi_reaper);
_beginthread(gdi_mouse_thread, 0, NULL); _beginthread(gdi_mouse_thread, 0, NULL);
_beginthread(gdi_thread, 0, NULL); _beginthread(gdi_thread, 0, NULL);
WaitForSingleObject(init_sem, INFINITE); WaitForSingleObject(init_sem, INFINITE);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment