mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-23 17:30:17 +01:00
Fix crash in clip shifting menu items
This commit is contained in:
@@ -654,29 +654,30 @@ double DoClipMove( AudacityProject &project, Track *track,
|
|||||||
if (!uShifter)
|
if (!uShifter)
|
||||||
return 0.0;
|
return 0.0;
|
||||||
auto pShifter = uShifter.get();
|
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 ),
|
state.Init( project, *track, hitTestResult, std::move( uShifter ),
|
||||||
t0, viewInfo, trackList, syncLocked );
|
t0, viewInfo, trackList, syncLocked );
|
||||||
|
|
||||||
auto desiredT0 = viewInfo.OffsetTimeByPixels( t0, ( right ? 1 : -1 ) );
|
|
||||||
auto desiredSlideAmount = pShifter->HintOffsetLarger( desiredT0 - t0 );
|
|
||||||
|
|
||||||
auto hSlideAmount = state.DoSlideHorizontal( desiredSlideAmount );
|
auto hSlideAmount = state.DoSlideHorizontal( desiredSlideAmount );
|
||||||
|
|
||||||
// update t0 and t1. There is the possibility that the updated
|
// update t0 and t1. There is the possibility that the updated
|
||||||
// t0 may no longer be within the clip due to rounding errors,
|
// t0 may no longer be within the clip due to rounding errors,
|
||||||
// so t0 is adjusted so that it is.
|
// so t0 is adjusted so that it is.
|
||||||
double newT0 = t0 + hSlideAmount;
|
double newT0 = t0 + hSlideAmount;
|
||||||
// pShifter is still undestroyed in the ClipMoveState
|
if (hitTestResult != TrackShifter::HitTestResult::Track) {
|
||||||
auto &intervals = pShifter->MovingIntervals();
|
// pShifter is still undestroyed in the ClipMoveState
|
||||||
if ( !intervals.empty() ) {
|
auto &intervals = pShifter->MovingIntervals();
|
||||||
auto &interval = intervals[0];
|
if ( !intervals.empty() ) {
|
||||||
if (newT0 < interval.Start())
|
auto &interval = intervals[0];
|
||||||
newT0 = interval.Start();
|
if (newT0 < interval.Start())
|
||||||
if (newT0 > interval.End())
|
newT0 = interval.Start();
|
||||||
newT0 = interval.End();
|
if (newT0 > interval.End())
|
||||||
double diff = selectedRegion.duration();
|
newT0 = interval.End();
|
||||||
selectedRegion.setTimes(newT0, newT0 + diff);
|
double diff = selectedRegion.duration();
|
||||||
|
selectedRegion.setTimes(newT0, newT0 + diff);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return hSlideAmount;
|
return hSlideAmount;
|
||||||
|
|||||||
Reference in New Issue
Block a user