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
This commit is contained in:
Vadim Zeitlin
2013-08-30 23:32:42 +00:00
parent 69384772ac
commit 3c3e94dc01

View File

@@ -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;