X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7631a29204a5a6a14c3ab6697455c48928ba6600..d78b3d64143f165857922e1e695ba4164d61869f:/src/common/wincmn.cpp diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index 582ea1e9bb..2665e8d0ec 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -191,6 +191,16 @@ wxWindowBase::~wxWindowBase() wxASSERT_MSG( GetChildren().GetCount() == 0, _T("children not destroyed") ); + // make sure that there are no dangling pointers left pointing to us + wxPanel *panel = wxDynamicCast(GetParent(), wxPanel); + if ( panel ) + { + if ( panel->GetLastFocus() == this ) + { + panel->SetLastFocus((wxWindow *)NULL); + } + } + #if wxUSE_CARET if ( m_caret ) delete m_caret; @@ -350,8 +360,9 @@ void wxWindowBase::Fit() int maxX = 0, maxY = 0; - wxWindowList::Node *node = GetChildren().GetFirst(); - while ( node ) + for ( wxWindowList::Node *node = GetChildren().GetFirst(); + node; + node = node->GetNext() ) { wxWindow *win = node->GetData(); if ( win->IsTopLevel() ) @@ -368,8 +379,6 @@ void wxWindowBase::Fit() maxX = wx + ww; if ( wy + wh > maxY ) maxY = wy + wh; - - node = node->GetNext(); } // leave a margin