From d5a4aa72e3e7ee373db72e775e8d49aaf2f60def Mon Sep 17 00:00:00 2001 From: lordmulder Date: Tue, 27 Dec 2011 05:47:38 +0100 Subject: [PATCH] Windows will kill our process immediately after we return from handling the WM_ENDSESSION message, so we have to clean-up explicitly *before* returning from the message handler. Not nice, but there is no other way. Also, as Windows will kill our process anyway and thus prevent a proper application shutdown, we can just call exit() from the message handler. This makes sure nothing "unexpected" can happen in the short moment that our application would continue to run after returning from the message handler. --- src/Config.h | 2 +- src/Global.cpp | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Config.h b/src/Config.h index b184f093..4d164739 100644 --- a/src/Config.h +++ b/src/Config.h @@ -30,7 +30,7 @@ #define VER_LAMEXP_MINOR_LO 4 #define VER_LAMEXP_TYPE Alpha #define VER_LAMEXP_PATCH 12 -#define VER_LAMEXP_BUILD 851 +#define VER_LAMEXP_BUILD 852 /////////////////////////////////////////////////////////////////////////////// // Tool versions (minimum expected versions!) diff --git a/src/Global.cpp b/src/Global.cpp index 2bb3f9a0..bdebebf4 100644 --- a/src/Global.cpp +++ b/src/Global.cpp @@ -808,7 +808,7 @@ static bool lamexp_event_filter(void *message, long *result) { app->closeAllWindows(); app->processEvents(); - Sleep(0); + Sleep(8); } } } @@ -818,9 +818,13 @@ static bool lamexp_event_filter(void *message, long *result) qWarning("WM_ENDSESSION message received!"); if(reinterpret_cast(message)->wParam == TRUE) { + g_sessionIsEnding = true; if(QApplication *app = reinterpret_cast(QApplication::instance())) { app->quit(); + app->processEvents(); + lamexp_finalization(); + exit(1); } } *result = 0;