From: Vadim Zeitlin Date: Sun, 12 Mar 2000 00:49:42 +0000 (+0000) Subject: fixed (rare but fatal) bug in wxWindowDisabler X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/79f585d90388128f9d245f7c92d3013b98b9ed14 fixed (rare but fatal) bug in wxWindowDisabler git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6631 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index 13270f231b..b8841a57b0 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -962,32 +962,8 @@ void wxEnableTopLevelWindows(bool enable) node->GetData()->Enable(enable); } -static void wxFindDisabledWindows(wxWindowList& winDisabled, - wxWindow *win, - wxWindow *winToSkip) -{ - wxWindowList::Node *node; - for ( node = win->GetChildren().GetFirst(); node; node = node->GetNext() ) - { - wxWindow *child = node->GetData(); - if ( child == winToSkip ) - continue; - - wxFindDisabledWindows(winDisabled, child, winToSkip); - - if ( child->IsEnabled() ) - { - winDisabled.Append(child); - child->Disable(); - } - } -} - wxWindowDisabler::wxWindowDisabler(wxWindow *winToSkip) { - // remember all windows we're going to (temporarily) disable - m_winDisabled = new wxWindowList; - #ifdef __WXMSW__ #ifdef __WIN32__ // and the top level window too @@ -999,16 +975,29 @@ wxWindowDisabler::wxWindowDisabler(wxWindow *winToSkip) #endif #endif // MSW + // remember the top level windows which were already disabled, so that we + // don't reenable them later + m_winDisabled = NULL; + wxWindowList::Node *node; for ( node = wxTopLevelWindows.GetFirst(); node; node = node->GetNext() ) { wxWindow *winTop = node->GetData(); - if ( winTop != winToSkip && winTop->IsEnabled() ) + if ( winTop == winToSkip ) + continue; + + if ( winTop->IsEnabled() ) { - wxFindDisabledWindows(*m_winDisabled, winTop, winToSkip); + winTop->Disable(); + } + else + { + if ( !m_winDisabled ) + { + m_winDisabled = new wxWindowList; + } m_winDisabled->Append(winTop); - winTop->Disable(); } } } @@ -1016,9 +1005,14 @@ wxWindowDisabler::wxWindowDisabler(wxWindow *winToSkip) wxWindowDisabler::~wxWindowDisabler() { wxWindowList::Node *node; - for ( node = m_winDisabled->GetFirst(); node; node = node->GetNext() ) + for ( node = wxTopLevelWindows.GetFirst(); node; node = node->GetNext() ) { - node->GetData()->Enable(); + wxWindow *winTop = node->GetData(); + if ( !m_winDisabled || !m_winDisabled->Find(winTop) ) + { + winTop->Enable(); + } + //else: had been already disabled, don't reenable } delete m_winDisabled;