From 5ed9fa972b8e01988e891d22d65e14ca43558c25 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Thu, 2 May 2019 07:00:25 -0400 Subject: [PATCH] AudacityProject::mIsBeingDeleted was redundant --- src/Project.cpp | 10 ++++------ src/Project.h | 5 ++--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/Project.cpp b/src/Project.cpp index 73048a9fc..ed571b392 100644 --- a/src/Project.cpp +++ b/src/Project.cpp @@ -2494,7 +2494,7 @@ void AudacityProject::OnActivate(wxActivateEvent & event) { // Activate events can fire during window teardown, so just // ignore them. - if (mIsDeleting) { + if (IsBeingDeleted()) { return; } @@ -2580,12 +2580,13 @@ public: // and/or attempts to DELETE objects twice. void AudacityProject::OnCloseWindow(wxCloseEvent & event) { + auto &window = *this; // We are called for the wxEVT_CLOSE_WINDOW, wxEVT_END_SESSION, and // wxEVT_QUERY_END_SESSION, so we have to protect against multiple // entries. This is a hack until the whole application termination // process can be reviewed and reworked. (See bug #964 for ways // to exercise the bug that instigated this hack.) - if (mIsBeingDeleted) + if (window.IsBeingDeleted()) { event.Skip(); return; @@ -2683,7 +2684,7 @@ void AudacityProject::OnCloseWindow(wxCloseEvent & event) // its size change. AllProjects::SaveWindowSize(); - mIsDeleting = true; + window.SetIsBeingDeleted(); // Mac: we never quit as the result of a close. // Other systems: we quit only when the close is the result of an external @@ -2817,9 +2818,6 @@ void AudacityProject::OnCloseWindow(wxCloseEvent & event) // Destroys this pSelf.reset(); mRuler = nullptr; - - mIsBeingDeleted = true; - } void AudacityProject::OnOpenAudioFile(wxCommandEvent & event) diff --git a/src/Project.h b/src/Project.h index ad48dc6f9..4ea0857a1 100644 --- a/src/Project.h +++ b/src/Project.h @@ -675,6 +675,8 @@ private: public: bool EmptyCanBeDirty() const { return mEmptyCanBeDirty; } + bool IsBeingDeleted() const { return mIsDeleting; } + void SetIsBeingDeleted() { mIsDeleting = true; } private: bool mIsSyncLocked; @@ -717,9 +719,6 @@ public: private: bool mbInitializingScrollbar{ false }; - // See explanation in OnCloseWindow - bool mIsBeingDeleted{ false }; - // TrackPanelOverlay objects std::shared_ptr mIndicatorOverlay, mCursorOverlay;