1
0
Fork 0

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.
This commit is contained in:
Robbert van der Helm 2022-08-29 13:59:06 +02:00
parent 3761f9f5ee
commit 2f87a79d3e

View file

@ -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<T, E> Drop for WindowsEventLoop<T, E> {
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()),