From 3c3e94dc01ce543f3d010778b443c14974121caa Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 30 Aug 2013 23:32:42 +0000 Subject: [PATCH] Fix infinite loop in wxMSW with wxStaticBox inside non-wxTAB_TRAVERSAL parent. We didn't ensure that the parent of a (native) control with WS_EX_CONTROLPARENT had this style as well, unlike for our own windows. Fix this now to make certain that we never call ::IsDialogMessage() on a window whose parent doesn't have WS_EX_CONTROLPARENT as it simply hangs in this case, entering an infinite loop searching for the default button. Also try to reduce the possibility of such bugs in the future by checking for WS_EX_CONTROLPARENT and not wxTAB_TRAVERSAL before calling ::IsDialogMessage() even if this doesn't totally prevent them (it wasn't sufficient to fix even this particular bug). Closes #15458. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74732 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/window.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/msw/window.cpp b/src/msw/window.cpp index c3e8c7f..a08d1fa 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -1200,6 +1200,11 @@ void wxWindowMSW::SubclassWin(WXHWND hWnd) if ( !wxCheckWindowWndProc(hWnd, (WXFARPROC)wxWndProc) ) { wxSetWindowProc(hwnd, wxWndProc); + + // If the window didn't use our window proc during its creation, the + // code in HandleCreate() hasn't been executed, so do it here. + if ( wxHasWindowExStyle(this, WS_EX_CONTROLPARENT) ) + EnsureParentHasControlParentStyle(GetParent()); } else { @@ -2298,7 +2303,12 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg) { // wxUniversal implements tab traversal itself #ifndef __WXUNIVERSAL__ - if ( m_hWnd != 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL) ) + // Notice that we check for WS_EX_CONTROLPARENT and not wxTAB_TRAVERSAL + // here. While usually they are both set or both unset, doing it like this + // also works if there is ever a bug that results in wxTAB_TRAVERSAL being + // set but not WS_EX_CONTROLPARENT as we must not call IsDialogMessage() in + // this case, it would simply hang (see #15458). + if ( m_hWnd != 0 && (wxGetWindowExStyle(this) & WS_EX_CONTROLPARENT) ) { // intercept dialog navigation keys MSG *msg = (MSG *)pMsg; -- 2.7.4