diff --git a/src/common/menucmn.cpp b/src/common/menucmn.cpp index 3b2c9d37aa..62118b53b5 100644 --- a/src/common/menucmn.cpp +++ b/src/common/menucmn.cpp @@ -537,6 +537,15 @@ wxMenuItem* wxMenuBase::FindItemByPosition(size_t position) const // window will be used. void wxMenuBase::UpdateUI(wxEvtHandler* source) { + if (GetInvokingWindow()) + { + // Don't update menus if the parent + // frame is about to get deleted + wxWindow *tlw = wxGetTopLevelParent( GetInvokingWindow() ); + if (tlw && wxPendingDelete.Member(tlw)) + return; + } + if ( !source && GetInvokingWindow() ) source = GetInvokingWindow()->GetEventHandler(); if ( !source ) diff --git a/src/common/tbarbase.cpp b/src/common/tbarbase.cpp index d78bcf6fe8..d2243fedf2 100644 --- a/src/common/tbarbase.cpp +++ b/src/common/tbarbase.cpp @@ -623,7 +623,8 @@ void wxToolBarBase::UpdateWindowUI(long flags) // There is no sense in updating the toolbar UI // if the parent window is about to get destroyed - if (GetParent() && wxPendingDelete.Member( GetParent() )) + wxWindow *tlw = wxGetTopLevelParent( this ); + if (tlw && wxPendingDelete.Member( tlw )) return; wxEvtHandler* evtHandler = GetEventHandler() ;