From 20b3fe76a844c49c5f1d9c1b964cd51656465aec Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Mon, 3 May 2021 13:53:39 +1000 Subject: [PATCH] playbackcache: fixed crash if shift was beyond length --- app/render/playbackcache.cpp | 14 +++++++++++++- app/render/playbackcache.h | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/render/playbackcache.cpp b/app/render/playbackcache.cpp index 349e9e33f..2398a3f80 100644 --- a/app/render/playbackcache.cpp +++ b/app/render/playbackcache.cpp @@ -87,12 +87,24 @@ void PlaybackCache::SetLength(const rational &r) } } -void PlaybackCache::Shift(const rational &from, const rational &to) +void PlaybackCache::Shift(rational from, rational to) { if (from == to) { return; } + if (from > length_) { + if (to > from) { + // No-op + return; + } else if (to >= length_) { + // No-op + return; + } else { + from = length_; + } + } + qDebug() << "FIXME: 0 job time may cause cache desyncs"; // An region between `from` and `to` will be inserted or spliced out diff --git a/app/render/playbackcache.h b/app/render/playbackcache.h index 2f5b39720..e2fb48fcb 100644 --- a/app/render/playbackcache.h +++ b/app/render/playbackcache.h @@ -69,7 +69,7 @@ public slots: void SetLength(const rational& r); - void Shift(const rational& from, const rational& to); + void Shift(rational from, rational to); signals: void Invalidated(const olive::TimeRange& r);