From f9e7c3a3dd3d11aad045e52665bde56c88a46f0f Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Tue, 5 Mar 2019 10:12:34 -0800 Subject: [PATCH] fixed crash when file contains no valid frames #601 --- rendering/cacher.cpp | 2 +- rendering/clipqueue.cpp | 5 +++++ rendering/clipqueue.h | 9 +++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/rendering/cacher.cpp b/rendering/cacher.cpp index eb33619b8..046cd936c 100644 --- a/rendering/cacher.cpp +++ b/rendering/cacher.cpp @@ -668,7 +668,7 @@ void Cacher::CacheVideoWorker() { qWarning() << clip->name() << "frame had no PTS value"; av_frame_free(&decoded_frame); - if (retrieve_code == AVERROR_EOF && retrieved_frame == nullptr) { + if (retrieve_code == AVERROR_EOF && retrieved_frame == nullptr && !queue.isEmpty()) { // if we reached the end of the file, it's not an error but there are no more frames to retrieve // some formats EOF before the end of the duration that Olive calculates. In this event, we simply // return the last frame we retrieved diff --git a/rendering/clipqueue.cpp b/rendering/clipqueue.cpp index bf86cdcd5..6ec335347 100644 --- a/rendering/clipqueue.cpp +++ b/rendering/clipqueue.cpp @@ -93,3 +93,8 @@ int ClipQueue::size() { return queue.size(); } + +bool ClipQueue::isEmpty() +{ + return queue.isEmpty(); +} diff --git a/rendering/clipqueue.h b/rendering/clipqueue.h index f06afc61d..3a023c62d 100644 --- a/rendering/clipqueue.h +++ b/rendering/clipqueue.h @@ -159,6 +159,15 @@ public: */ int size(); + /** + * @brief Returns whether the queue is empty of not. + * + * @return + * + * **TRUE** if the queue is empty and contains no frames, **FALSE** if not. + */ + bool isEmpty(); + private: QVector queue; QMutex queue_lock;