From 5a2eaf9a527b702f2bb6adb67cb530051c7baf84 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Tue, 25 Feb 2020 14:54:58 -0500 Subject: [PATCH] Bug2303: Play after project open should start at saved cursor --- src/ViewInfo.cpp | 18 ++++++++++++++++-- src/ViewInfo.h | 6 ++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/ViewInfo.cpp b/src/ViewInfo.cpp index e9597ea54..b0c20ae88 100644 --- a/src/ViewInfo.cpp +++ b/src/ViewInfo.cpp @@ -34,6 +34,17 @@ wxEvent *SelectedRegionEvent::Clone() const return safenew SelectedRegionEvent{ *this }; } +bool NotifyingSelectedRegion::HandleXMLAttribute + (const wxChar *attr, const wxChar *value, + const wxChar *legacyT0Name, const wxChar *legacyT1Name) +{ + auto result = mRegion.HandleXMLAttribute( + attr, value, legacyT0Name, legacyT1Name ); + if ( result ) + Notify( true ); + return result; +} + NotifyingSelectedRegion& NotifyingSelectedRegion::operator = ( const SelectedRegion &other ) { @@ -128,10 +139,13 @@ bool NotifyingSelectedRegion::setF1(double f, bool maySwap) return result; } -void NotifyingSelectedRegion::Notify() +void NotifyingSelectedRegion::Notify( bool delayed ) { SelectedRegionEvent evt{ EVT_SELECTED_REGION_CHANGE, this }; - ProcessEvent( evt ); + if ( delayed ) + QueueEvent( evt.Clone() ); + else + ProcessEvent( evt ); } static const AudacityProject::AttachedObjects::RegisteredFactory key{ diff --git a/src/ViewInfo.h b/src/ViewInfo.h index ca34c8205..eb3d143cc 100644 --- a/src/ViewInfo.h +++ b/src/ViewInfo.h @@ -59,9 +59,7 @@ public: bool HandleXMLAttribute (const wxChar *attr, const wxChar *value, - const wxChar *legacyT0Name, const wxChar *legacyT1Name) - { return mRegion.HandleXMLAttribute( - attr, value, legacyT0Name, legacyT1Name ); } + const wxChar *legacyT0Name, const wxChar *legacyT1Name); // const-only access allows assignment from this into a SelectedRegion // or otherwise passing it into a function taking const SelectedRegion& @@ -95,7 +93,7 @@ public: bool setF1(double f, bool maySwap = true); private: - void Notify(); + void Notify( bool delayed = false ); SelectedRegion mRegion; };