From 593cc6ee5ee15640388253957c9cda5ae80d594b Mon Sep 17 00:00:00 2001 From: James Crook Date: Fri, 24 Apr 2015 09:55:03 +0100 Subject: [PATCH] Bug 855 - Data loss sample editing (Do/Undo) I've added code that now treats sample editing as another kind of mouse capturing activity (IsAdjustingSample). We will now not undo or redo whilst mouse is captured. Does not depend on what key binding is used for redo/undo. --- src/Menus.cpp | 4 ++++ src/TrackPanel.cpp | 4 +++- src/TrackPanel.h | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Menus.cpp b/src/Menus.cpp index 31773b346..5bc6c4bfc 100644 --- a/src/Menus.cpp +++ b/src/Menus.cpp @@ -3503,6 +3503,10 @@ void AudacityProject::OnRedo() wxMessageBox(_("Nothing to redo")); return; } + // Can't redo whilst dragging + if (mTrackPanel->IsMouseCaptured()) { + return; + } TrackList *l = mUndoManager.Redo(&mViewInfo.selectedRegion); PopState(l); diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index d5bd3592f..efb9e7cc5 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -1578,6 +1578,7 @@ void TrackPanel::HandleEscapeKey() break; case IsZooming: case IsVZooming: + case IsAdjustingSample: break; case IsResizing: mCapturedTrack->SetHeight(mInitialActualHeight); @@ -4906,6 +4907,7 @@ void TrackPanel::HandleSampleEditingClick( wxMouseEvent & event ) ReleaseMouse(); return; } + SetCapturedTrack( t, IsAdjustingSample); /// \todo Should mCapturedTrack take the place of mDrawingTrack?? mDrawingTrack = t; @@ -5149,7 +5151,7 @@ void TrackPanel::HandleSampleEditingButtonUp( wxMouseEvent & WXUNUSED(event)) //************************************************* //*** UP-CLICK (Finish drawing) *** //************************************************* - + SetCapturedTrack( NULL ); //On up-click, send the state to the undo stack mDrawingTrack=NULL; //Set this to NULL so it will catch improper drag events. MakeParentPushState(_("Moved Sample"), diff --git a/src/TrackPanel.h b/src/TrackPanel.h index e33ad144e..cb60bc07c 100644 --- a/src/TrackPanel.h +++ b/src/TrackPanel.h @@ -746,6 +746,7 @@ protected: IsClosing, IsSelecting, IsAdjustingLabel, + IsAdjustingSample, IsResizing, IsResizingBetweenLinkedTracks, IsResizingBelowLinkedTracks,