1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-31 07:59:27 +02:00

Fix crash in clip shifting menu items

This commit is contained in:
Paul Licameli 2020-09-29 13:27:34 -04:00
parent dd6fe21853
commit aabcc24cdb

View File

@ -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;