From 95560ad510425e9a066aaf32e3015d6896cb0233 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 7 Aug 2017 18:44:36 -0400 Subject: [PATCH] Bug1676, more: don't bother caching the first visible track... ... because the sequence of update of the cache and the use of it were wrong on Linux, resulting in wrong display when dragging tracks. Finding the first visible track is too cheap to justify this memoizing of it. Commit 8eb64f5f71d19a4c634cb8312fd1fa93ac75f17f was not sufficient to fix the bug, but I think remains necessary. It feels good to throw away this needless complication. --- src/Project.cpp | 53 ++----------------------------------------------- src/Project.h | 2 -- src/ViewInfo.h | 2 -- 3 files changed, 2 insertions(+), 55 deletions(-) diff --git a/src/Project.cpp b/src/Project.cpp index b0a346ceb..bab32eb4b 100644 --- a/src/Project.cpp +++ b/src/Project.cpp @@ -949,20 +949,6 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id, mLastSavedTracks.reset(); - // Register for tracklist updates - mTracks->Connect(EVT_TRACKLIST_PERMUTED, - wxCommandEventHandler(AudacityProject::OnTrackListUpdate), - NULL, - this); - mTracks->Connect(EVT_TRACKLIST_DELETION, - wxCommandEventHandler(AudacityProject::OnTrackListUpdate), - NULL, - this); - mTracks->Connect(EVT_TRACKLIST_RESIZING, - wxCommandEventHandler(AudacityProject::OnTrackListUpdate), - NULL, - this); - // // Initialize view info (shared with TrackPanel) // @@ -1984,9 +1970,6 @@ void AudacityProject::FixScrollbars() rescroll = false; } - if (lastv != mViewInfo.vpos) - InvalidateFirstVisible(); - // wxScrollbar only supports int values but we need a greater range, so // we scale the scrollbar coordinates on demand. We only do this if we // would exceed the int range, so we can always use the maximum resolution @@ -2035,8 +2018,8 @@ void AudacityProject::FixScrollbars() std::shared_ptr AudacityProject::GetFirstVisible() { - auto pTrack = mViewInfo.track.lock(); - if (!pTrack && GetTracks()) { + std::shared_ptr pTrack; + if (GetTracks()) { // Recompute on demand and memo-ize TrackListIterator iter(GetTracks()); for (Track *t = iter.First(); t; t = iter.Next()) { @@ -2048,17 +2031,11 @@ std::shared_ptr AudacityProject::GetFirstVisible() break; } } - mViewInfo.track = pTrack; } return pTrack; } -void AudacityProject::InvalidateFirstVisible() -{ - mViewInfo.track.reset(); -} - void AudacityProject::UpdateLayout() { if (!mTrackPanel) @@ -2213,14 +2190,6 @@ void AudacityProject::OnToolBarUpdate(wxCommandEvent & event) event.Skip(false); /* No need to propagate any further */ } -// The projects tracklist has been updated -void AudacityProject::OnTrackListUpdate(wxCommandEvent & event) -{ - InvalidateFirstVisible(); - - event.Skip(); -} - ///Handles the redrawing necessary for tasks as they partially update in the background. void AudacityProject::OnODTaskUpdate(wxCommandEvent & WXUNUSED(event)) { @@ -2267,9 +2236,6 @@ void AudacityProject::DoScroll() int lastv = mViewInfo.vpos; mViewInfo.vpos = mVsbar->GetThumbPosition() * mViewInfo.scrollStep; - if (lastv != mViewInfo.vpos) - InvalidateFirstVisible(); - //mchinen: do not always set this project to be the active one. //a project may autoscroll while playing in the background //I think this is okay since OnMouseEvent has one of these. @@ -2675,20 +2641,6 @@ void AudacityProject::OnCloseWindow(wxCloseEvent & event) mImportXMLTagHandler.reset(); - // Unregister for tracklist updates - mTracks->Disconnect(EVT_TRACKLIST_PERMUTED, - wxCommandEventHandler(AudacityProject::OnTrackListUpdate), - NULL, - this); - mTracks->Disconnect(EVT_TRACKLIST_DELETION, - wxCommandEventHandler(AudacityProject::OnTrackListUpdate), - NULL, - this); - mTracks->Disconnect(EVT_TRACKLIST_RESIZING, - wxCommandEventHandler(AudacityProject::OnTrackListUpdate), - NULL, - this); - // Delete all the tracks to free up memory and DirManager references. mTracks->Clear(); mTracks.reset(); @@ -3523,7 +3475,6 @@ bool AudacityProject::HandleXMLTag(const wxChar *tag, const wxChar **attrs) if (longVpos != 0) { // PRL: It seems this must happen after SetSnapTo - mViewInfo.track.reset(); mViewInfo.vpos = longVpos; mbInitializingScrollbar = true; } diff --git a/src/Project.h b/src/Project.h index ad24a97db..3683bb928 100644 --- a/src/Project.h +++ b/src/Project.h @@ -192,7 +192,6 @@ class AUDACITY_DLL_API AudacityProject final : public wxFrame, ViewInfo &GetViewInfo() { return mViewInfo; } std::shared_ptr GetFirstVisible(); - void InvalidateFirstVisible(); void GetPlayRegion(double* playRegionStart, double *playRegionEnd); bool IsPlayRegionLocked() { return mLockPlayRegion; } @@ -357,7 +356,6 @@ public: void OnOpenAudioFile(wxCommandEvent & event); void OnODTaskUpdate(wxCommandEvent & event); void OnODTaskComplete(wxCommandEvent & event); - void OnTrackListUpdate(wxCommandEvent & event); void HandleResize(); void UpdateLayout(); diff --git a/src/ViewInfo.h b/src/ViewInfo.h index 797bafd15..52b272fee 100644 --- a/src/ViewInfo.h +++ b/src/ViewInfo.h @@ -158,8 +158,6 @@ public: // Scroll info - std::weak_ptr track; // first visible track - double total; // total width in secs // Current horizontal scroll bar positions, in pixels wxInt64 sbarH;