From ada8f807758339fe6a80070fe0935d87496dbe57 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Sat, 26 May 2001 22:20:33 +0000 Subject: [PATCH] another attempt to fix wxPanel/wxFrame::m_winLastFocused handling git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10341 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/generic/panelg.h | 2 ++ src/common/wincmn.cpp | 10 ---------- src/generic/panelg.cpp | 7 +++++++ 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/include/wx/generic/panelg.h b/include/wx/generic/panelg.h index eda2bd5abd..5d9f2a0f0a 100644 --- a/include/wx/generic/panelg.h +++ b/include/wx/generic/panelg.h @@ -97,6 +97,8 @@ public: void SetLastFocus(wxWindow *win) { m_winLastFocused = win; } wxWindow *GetLastFocus() const { return m_winLastFocused; } + virtual void RemoveChild(wxWindowBase *child); + protected: // common part of all ctors void Init(); diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index 95c51f5899..26eb1fb525 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -225,16 +225,6 @@ wxWindowBase::~wxWindowBase() wxASSERT_MSG( GetChildren().GetCount() == 0, wxT("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; diff --git a/src/generic/panelg.cpp b/src/generic/panelg.cpp index 3052aabd7b..7bded1cd15 100644 --- a/src/generic/panelg.cpp +++ b/src/generic/panelg.cpp @@ -284,6 +284,13 @@ void wxPanel::OnNavigationKey( wxNavigationKeyEvent& event ) event.Skip(); } +void wxPanel::RemoveChild(wxWindowBase *child) +{ + if ( child == m_winLastFocused ) + m_winLastFocused = NULL; + wxWindow::RemoveChild(child); +} + void wxPanel::SetFocus() { wxLogTrace(_T("focus"), _T("SetFocus on wxPanel 0x%08x."), GetHandle()); -- 2.45.2