From 2fb18e8961a09aa9a144f1fb057f300a9fea8d00 Mon Sep 17 00:00:00 2001 From: James Crook Date: Sat, 3 Sep 2016 20:19:34 +0100 Subject: [PATCH] Bug 1496 - Mouse down while undoing in Envelope Tool corrupts Undo stack The Ctrl-Z was interrupting the enveloping, making it finish, but it then got asked to finish again on a mouse up. This change stops the second finish from happening. --- src/TrackPanel.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index 6def028ec..4825f35ec 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -1167,8 +1167,12 @@ void TrackPanel::HandleInterruptedDrag() WasOverCutLine, IsStretching */ - + // The bogus id isn't used anywhere, but may help with debugging. + // as this is sending a bogus mouse up. The mouse button is still actually down + // and may go up again. + const int idBogusUp = 2; wxMouseEvent evt { wxEVT_LEFT_UP }; + evt.SetId( idBogusUp ); evt.SetPosition(this->ScreenToClient(::wxGetMousePosition())); this->ProcessEvent(evt); } @@ -3068,7 +3072,10 @@ void TrackPanel::HandleEnvelope(wxMouseEvent & event) if (mCapturedTrack) ForwardEventToEnvelope(event); - if (event.LeftUp()) { + // We test for IsEnveloping, because we could have had our action stopped already, + // and already recorded and the second mouse up is bogus. + // e.g could be stopped by some key press. Bug 1496. + if ((mMouseCapture == IsEnveloping ) && event.LeftUp()) { SetCapturedTrack( NULL ); MakeParentPushState( /* i18n-hint: (verb) Audacity has just adjusted the envelope .*/