From 18759f7850414f46b15a8ed989951e3bc346f830 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 10 Jul 2003 09:32:35 +0000 Subject: [PATCH] applied an extended version of patch 685795: clean up view [de]activation git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21845 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/docview.h | 2 +- src/common/docview.cpp | 38 +++++++++++++++----------------------- 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/include/wx/docview.h b/include/wx/docview.h index b5c29be..ad37b58 100644 --- a/include/wx/docview.h +++ b/include/wx/docview.h @@ -379,7 +379,7 @@ public: // Views or windows should inform the document manager // when a view is going in or out of focus - virtual void ActivateView(wxView *view, bool activate = TRUE, bool deleting = FALSE); + virtual void ActivateView(wxView *view, bool activate = TRUE); virtual wxView *GetCurrentView() const; wxList& GetDocuments() { return m_docs; } diff --git a/src/common/docview.cpp b/src/common/docview.cpp index 0616423..e072005 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -568,16 +568,14 @@ void wxDocument::SetFilename(const wxString& filename, bool notifyViews) wxView::wxView() { - // SetDocument(doc); m_viewDocument = (wxDocument*) NULL; - m_viewTypeName = wxT(""); m_viewFrame = (wxFrame *) NULL; } wxView::~wxView() { -// GetDocumentManager()->ActivateView(this, FALSE, TRUE); + GetDocumentManager()->ActivateView(this, FALSE); m_viewDocument->RemoveView(this); } @@ -586,8 +584,8 @@ bool wxView::ProcessEvent(wxEvent& event) { if ( !GetDocument() || !GetDocument()->ProcessEvent(event) ) return wxEvtHandler::ProcessEvent(event); - else - return TRUE; + + return TRUE; } void wxView::OnActivateView(bool WXUNUSED(activate), wxView *WXUNUSED(activeView), wxView *WXUNUSED(deactiveView)) @@ -1710,25 +1708,19 @@ void wxDocManager::RemoveDocument(wxDocument *doc) // Views or windows should inform the document manager // when a view is going in or out of focus -void wxDocManager::ActivateView(wxView *view, bool activate, bool WXUNUSED(deleting)) -{ - // If we're deactiving, and if we're not actually deleting the view, then - // don't reset the current view because we may be going to - // a window without a view. - // WHAT DID I MEAN BY THAT EXACTLY? - /* - if (deleting) - { - if (m_currentView == view) - m_currentView = NULL; - } - else - */ - { - if (activate) - m_currentView = view; - else +void wxDocManager::ActivateView(wxView *view, bool activate) +{ + if ( activate ) + { + m_currentView = view; + } + else // deactivate + { + if ( m_currentView == view ) + { + // don't keep stale pointer m_currentView = (wxView *) NULL; + } } } -- 2.7.4