X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ef37a43194e06496cba74b1f0d0ab9eeefde4af7..edd6813c826edc2311548da53eb83e7f1bc18d2b:/src/common/toplvcmn.cpp?ds=sidebyside diff --git a/src/common/toplvcmn.cpp b/src/common/toplvcmn.cpp index 4e501fa79d..bcfd529105 100644 --- a/src/common/toplvcmn.cpp +++ b/src/common/toplvcmn.cpp @@ -118,15 +118,26 @@ bool wxTopLevelWindowBase::Destroy() if ( !wxPendingDelete.Member(this) ) wxPendingDelete.Append(this); - if (wxTopLevelWindows.GetCount() > 1) + // normally we want to hide the window immediately so that it doesn't get + // stuck on the screen while it's being destroyed, however we shouldn't + // hide the last visible window as then we might not get any idle events + // any more as no events will be sent to the hidden window and without idle + // events we won't prune wxPendingDelete list and the application won't + // terminate + for ( wxWindowList::const_iterator i = wxTopLevelWindows.begin(), + end = wxTopLevelWindows.end(); + i != end; + ++i ) { - // Hide it immediately. This should - // not be done if this TLW is the - // only one left since we then would - // risk not to get any idle events - // at all anymore during which we - // could delete any pending events. - Hide(); + wxTopLevelWindow * const win = wx_static_cast(wxTopLevelWindow *, *i); + if ( win != this && win->IsShown() ) + { + // there remains at least one other visible TLW, we can hide this + // one + Hide(); + + break; + } } return true;