Fixed a crash on exit by calling DefWindowProc after the WM_DESTORY message has been received. Patch by eddie.willett.

Fixes issue 4588.
Fixes issue 5285.
This commit is contained in:
skidau 2012-03-19 21:51:26 +11:00
parent 418f46ea72
commit 281d7531a3
2 changed files with 8 additions and 7 deletions

View File

@ -365,7 +365,7 @@ public:
virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
// Calls an appropriate default window procedure // Calls an appropriate default window procedure
virtual WXLRESULT MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); virtual WXLRESULT MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam, bool callDefWindowProc = false);
// message processing helpers // message processing helpers

View File

@ -2234,9 +2234,9 @@ bool wxWindowMSW::DoPopupMenu(wxMenu *menu, int x, int y)
// pre/post message processing // pre/post message processing
// =========================================================================== // ===========================================================================
WXLRESULT wxWindowMSW::MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) WXLRESULT wxWindowMSW::MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam, bool callDefWindowProc /* = false */)
{ {
if ( m_oldWndProc ) if (!callDefWindowProc && m_oldWndProc)
return ::CallWindowProc(CASTWNDPROC m_oldWndProc, GetHwnd(), (UINT) nMsg, (WPARAM) wParam, (LPARAM) lParam); return ::CallWindowProc(CASTWNDPROC m_oldWndProc, GetHwnd(), (UINT) nMsg, (WPARAM) wParam, (LPARAM) lParam);
else else
return ::DefWindowProc(GetHwnd(), nMsg, wParam, lParam); return ::DefWindowProc(GetHwnd(), nMsg, wParam, lParam);
@ -2653,11 +2653,12 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l
break; break;
case WM_DESTROY: case WM_DESTROY:
// never set processed to true and *always* pass WM_DESTROY to // *always* pass WM_DESTROY to DefWindowProc() as Windows may do
// DefWindowProc() as Windows may do some internal cleanup when // some internal cleanup when processing it and failing to pass
// processing it and failing to pass the message along may cause // the message along may cause memory and resource leaks!
// memory and resource leaks!
(void)HandleDestroy(); (void)HandleDestroy();
rc.result = MSWDefWindowProc(message, wParam, lParam, true);
processed = true;
break; break;
case WM_SIZE: case WM_SIZE: