X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/214b94848a50b224aa3b2101b21149ae82e3706f..93c2f401e9955dc37df1f8dbfea7881c676b8ddb:/src/common/tbarbase.cpp diff --git a/src/common/tbarbase.cpp b/src/common/tbarbase.cpp index 69f106b9ee..2d250e20d5 100644 --- a/src/common/tbarbase.cpp +++ b/src/common/tbarbase.cpp @@ -114,10 +114,6 @@ bool wxToolBarToolBase::SetLongHelp(const wxString& help) return true; } -wxToolBarToolBase::~wxToolBarToolBase() -{ -} - // ---------------------------------------------------------------------------- // wxToolBarBase adding/deleting items // ---------------------------------------------------------------------------- @@ -423,6 +419,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); + } } // ---------------------------------------------------------------------------- @@ -611,8 +615,10 @@ void wxToolBarBase::OnMouseEnter(int id) wxFrame *frame = wxDynamicCast(GetParent(), wxFrame); if( frame ) { - wxToolBarToolBase* tool = id == wxID_ANY ? (wxToolBarToolBase*)0 : FindById(id); - wxString help = tool ? tool->GetLongHelp() : wxString(); + wxString help; + wxToolBarToolBase* tool = id == wxID_ANY ? (wxToolBarToolBase*)NULL : FindById(id); + if(tool) + help = tool->GetLongHelp(); frame->DoGiveHelp( help, id != wxID_ANY ); }