From 1ba100fed0c5ede39a18a5bee4d3869893f37c4b Mon Sep 17 00:00:00 2001 From: gocha Date: Tue, 21 Aug 2012 22:21:38 +0900 Subject: [PATCH] win32: fix a crash caused by WatcherThread. Lua Console must dispatch WM_DESTROY instead of WM_CLOSE. --- win32/luaconsole.cpp | 12 ++++++++++++ win32/wsnes9x.cpp | 3 --- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/win32/luaconsole.cpp b/win32/luaconsole.cpp index 917da045..fc42946c 100644 --- a/win32/luaconsole.cpp +++ b/win32/luaconsole.cpp @@ -699,6 +699,10 @@ LRESULT CALLBACK LuaScriptProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara } break; case WM_CLOSE: + DestroyWindow(hDlg); + return true; + + case WM_DESTROY: { LuaPerWindowInfo& info = LuaWindowInfo[hDlg]; @@ -820,4 +824,12 @@ const char* OpenLuaScript(const char* filename, const char* extraDirToCheck, boo return NULL; } +void CloseAllLuaWindows() +{ + for (int i = 0; i < LuaScriptHWnds.size(); i++) + { + SendMessage(LuaScriptHWnds[i], WM_CLOSE, 0, 0); + } +} + #endif // HAVE_LUA diff --git a/win32/wsnes9x.cpp b/win32/wsnes9x.cpp index 4ee0cfc3..8701c142 100644 --- a/win32/wsnes9x.cpp +++ b/win32/wsnes9x.cpp @@ -3674,9 +3674,6 @@ int WINAPI WinMain( loop_exit: -#ifdef HAVE_LUA - StopAllLuaScripts(); -#endif CloseAllToolWindows(); Settings.StopEmulation = TRUE;