From efde85e8ca9688b1b9ca9233dc98eb3029543488 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Fri, 4 Nov 2016 14:01:25 +0100 Subject: [PATCH] demos: Properly destroy windows on Win32. --- demos/demo_win32.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/demos/demo_win32.h b/demos/demo_win32.h index 1e79b667..92cde9b0 100644 --- a/demos/demo_win32.h +++ b/demos/demo_win32.h @@ -96,11 +96,7 @@ static inline struct demo_window *demo_window_create(struct demo *demo, const ch static inline void demo_window_destroy(struct demo_window *window) { - if (window->hwnd) - DestroyWindow(window->hwnd); - if (!--window->demo->window_count) - window->demo->quit = true; - free(window); + DestroyWindow(window->hwnd); } static inline demo_key demo_key_from_vkey(DWORD vkey) @@ -128,8 +124,9 @@ static inline LRESULT CALLBACK demo_window_proc(HWND hwnd, UINT message, WPARAM return 0; case WM_DESTROY: - window->hwnd = NULL; - demo_window_destroy(window); + if (!--window->demo->window_count) + window->demo->quit = true; + free(window); return 0; }