From 061bfe9e2b9ab6bb87e7c439d35f64b2f1a21805 Mon Sep 17 00:00:00 2001 From: Mathieu Schroeter Date: Thu, 2 Feb 2017 17:57:51 +0100 Subject: [PATCH] Fix timer lifetime --- blupi.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/blupi.cpp b/blupi.cpp index 6658b84..d321889 100644 --- a/blupi.cpp +++ b/blupi.cpp @@ -366,7 +366,6 @@ LRESULT CALLBACK WindowProc2 (HWND hWnd, UINT message, break; case WM_DESTROY: - KillTimer(g_hWnd, 1); FinishObjects(); PostQuitMessage(0); break; @@ -777,13 +776,12 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, return false; } - SDL_TimerID my_timer_id = SDL_AddTimer (g_timerInterval, [] (Uint32 interval, void *param) -> Uint32 + SDL_TimerID updateTimer = SDL_AddTimer (g_timerInterval, [] (Uint32 interval, void *param) -> Uint32 { CEvent::PushUserEvent (WM_UPDATE); return interval; }, nullptr); - while (SDL_TRUE) { if ( PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) ) @@ -816,6 +814,7 @@ out: if (g_window) SDL_DestroyWindow (g_window); + SDL_RemoveTimer (updateTimer); SDL_Quit (); return static_cast (msg.wParam); }