From 2f87a79d3eaf817576067e8e66cae637505fcc8c Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Mon, 29 Aug 2022 13:59:06 +0200 Subject: [PATCH] Wait for the Windows event loop to shut down This fixes crashes when removing the instance and immediately unloading the module. `DestroyWindow()` is synchronous while `CloseWindow()` merely posts a message to close the window. --- src/event_loop/windows.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/event_loop/windows.rs b/src/event_loop/windows.rs index 66411fb9..714d8d67 100644 --- a/src/event_loop/windows.rs +++ b/src/event_loop/windows.rs @@ -13,7 +13,7 @@ use windows::Win32::System::{ LibraryLoader::GetModuleHandleA, Performance::QueryPerformanceCounter, }; use windows::Win32::UI::WindowsAndMessaging::{ - CloseWindow, CreateWindowExA, DefWindowProcA, GetWindowLongPtrA, PostMessageA, + CreateWindowExA, DefWindowProcA, DestroyWindow, GetWindowLongPtrA, PostMessageA, RegisterClassExA, SetWindowLongPtrA, UnregisterClassA, CREATESTRUCTA, GWLP_USERDATA, HMENU, WINDOW_EX_STYLE, WINDOW_STYLE, WM_CREATE, WM_DESTROY, WM_USER, WNDCLASSEXA, }; @@ -171,7 +171,7 @@ where impl Drop for WindowsEventLoop { fn drop(&mut self) { - unsafe { CloseWindow(self.message_window) }; + unsafe { DestroyWindow(self.message_window) }; unsafe { UnregisterClassA( PSTR(self.message_window_class_name.as_bytes_with_nul().as_ptr()),