From aabcc24cdbbf4b42f489aa1809a129b322833c28 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Tue, 29 Sep 2020 13:27:34 -0400 Subject: [PATCH] Fix crash in clip shifting menu items --- src/menus/ClipMenus.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/menus/ClipMenus.cpp b/src/menus/ClipMenus.cpp index 2ebe2ec39..72a39a4a6 100644 --- a/src/menus/ClipMenus.cpp +++ b/src/menus/ClipMenus.cpp @@ -654,29 +654,30 @@ double DoClipMove( AudacityProject &project, Track *track, if (!uShifter) return 0.0; auto pShifter = uShifter.get(); + auto desiredT0 = viewInfo.OffsetTimeByPixels( t0, ( right ? 1 : -1 ) ); + auto desiredSlideAmount = pShifter->HintOffsetLarger( desiredT0 - t0 ); state.Init( project, *track, hitTestResult, std::move( uShifter ), t0, viewInfo, trackList, syncLocked ); - auto desiredT0 = viewInfo.OffsetTimeByPixels( t0, ( right ? 1 : -1 ) ); - auto desiredSlideAmount = pShifter->HintOffsetLarger( desiredT0 - t0 ); - auto hSlideAmount = state.DoSlideHorizontal( desiredSlideAmount ); // update t0 and t1. There is the possibility that the updated // t0 may no longer be within the clip due to rounding errors, // so t0 is adjusted so that it is. double newT0 = t0 + hSlideAmount; - // pShifter is still undestroyed in the ClipMoveState - auto &intervals = pShifter->MovingIntervals(); - if ( !intervals.empty() ) { - auto &interval = intervals[0]; - if (newT0 < interval.Start()) - newT0 = interval.Start(); - if (newT0 > interval.End()) - newT0 = interval.End(); - double diff = selectedRegion.duration(); - selectedRegion.setTimes(newT0, newT0 + diff); + if (hitTestResult != TrackShifter::HitTestResult::Track) { + // pShifter is still undestroyed in the ClipMoveState + auto &intervals = pShifter->MovingIntervals(); + if ( !intervals.empty() ) { + auto &interval = intervals[0]; + if (newT0 < interval.Start()) + newT0 = interval.Start(); + if (newT0 > interval.End()) + newT0 = interval.End(); + double diff = selectedRegion.duration(); + selectedRegion.setTimes(newT0, newT0 + diff); + } } return hSlideAmount;