Permalink
Browse files

Fix bug not shutting down LK correctly if a dialog window is open.

This could be possible only on PC version, where you can click on the X corner to quit a program.
But the bug would hit even resized LK instances on CE.
The Close() was missing, and when clicking on X to quit LK, if a dialog was pending it was not
closed correctly: the modal dialog had previously stopped the message loop dispatcher, and
as a result inside the main message loop in lk8000.cpp we were not getting the QUIT message.
So the main thread was left running, as a ghost process. This could happen only on PC, so far,
but was a pending problem for the cases when we have a full window where you can click an X to quit.

It remains the question: why WM_CLOSE is not sent to WindowControls message manager? Never mind since
we now handle the close directly from WM_DESTROY.
  • Loading branch information...
pventafridda committed Feb 20, 2012
1 parent 2a22b01 commit 03c809f1f6ff204704ed4cc8e6a457313f5d0d3e
Showing with 8 additions and 5 deletions.
  1. +8 −0 Common/Source/WindowControls.cpp
  2. +0 −5 Common/Source/WndProc.cpp
@@ -1980,6 +1980,13 @@ int WindowControl::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
#if TRACE_WNDPROC
StartupStore(_T(".... WNDPROC> DESTROY\n"));
#endif
+ // The Close() was missing, and when clicking on X to quit LK, if a dialog was pending it was not
+ // closed correctly: the modal dialog had previously stopped the message loop dispatcher, and
+ // as a result inside the main message loop in lk8000.cpp we were not getting the QUIT message.
+ // So the main thread was left running, as a ghost process. This could happen only on PC, so far,
+ // but was a pending problem for the cases when we have a full window where you can click an X to quit.
+ Close();
+
break;
case WM_COMMAND:
@@ -2064,6 +2071,7 @@ int WindowControl::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
*/
break;
+ // APPARENTLY THIS IS NEVER CALLED. Missing Close(), handled by Destroy() now
case WM_QUIT:
case WM_CLOSE:
TouchContext=TCX_PROC_CLOSE;
@@ -411,11 +411,6 @@ void Shutdown(void) {
}
StartupStore(_T(". Finished shutdown %s%s"), WhatTimeIsIt(),NEWLINE);
LKRunStartEnd(false);
- // quitting PC version while menus are up will not terminate correctly. this is a workaround
- #if (WINDOWSPC>0)
- StartupStore(TEXT(". Program terminated%s"),NEWLINE);
- exit(0);
- #endif
#ifdef DEBUG
TCHAR foop[80];

0 comments on commit 03c809f

Please sign in to comment.