From: Vadim Zeitlin Date: Sat, 16 Oct 2004 20:25:39 +0000 (+0000) Subject: reset parent frame tool/status bar pointer automatically when the bar is destroyed... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/2ab822146cad04a848d61c886e6ab9a3bdbe2c89 reset parent frame tool/status bar pointer automatically when the bar is destroyed; this ensures that we're never left with dangling pointers and fixes a crash under Mac when MDI child frame with a toolbar is closed git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29923 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/common/statbar.cpp b/src/common/statbar.cpp index 492573e98b..1a0b98a561 100644 --- a/src/common/statbar.cpp +++ b/src/common/statbar.cpp @@ -61,6 +61,14 @@ wxStatusBarBase::~wxStatusBarBase() FreeWidths(); FreeStacks(); InitStyles(); + + // notify the frame that it doesn't have a status bar any longer to avoid + // dangling pointers + wxFrameBase *frame = wxDynamicCast(GetParent(), wxFrameBase); + if ( frame && frame->GetStatusBar() == this ) + { + frame->SetStatusBar(NULL); + } } // ---------------------------------------------------------------------------- diff --git a/src/common/tbarbase.cpp b/src/common/tbarbase.cpp index 57daadc573..0bd33adcaf 100644 --- a/src/common/tbarbase.cpp +++ b/src/common/tbarbase.cpp @@ -423,6 +423,14 @@ bool wxToolBarBase::Realize() wxToolBarBase::~wxToolBarBase() { WX_CLEAR_LIST(wxToolBarToolsList, m_tools); + + // notify the frame that it doesn't have a tool bar any longer to avoid + // dangling pointers + wxFrameBase *frame = wxDynamicCast(GetParent(), wxFrameBase); + if ( frame && frame->GetToolBar() == this ) + { + frame->SetToolBar(NULL); + } } // ----------------------------------------------------------------------------