From 00fef29cac99a013d589c5406cab13b2b41a8b60 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Thu, 29 Oct 2020 02:18:58 +1100 Subject: [PATCH] fixed issues where hashes wouldn't set correctly --- app/render/previewautocacher.cpp | 54 ++++++++++++++++++++++---------- app/render/previewautocacher.h | 3 +- 2 files changed, 40 insertions(+), 17 deletions(-) diff --git a/app/render/previewautocacher.cpp b/app/render/previewautocacher.cpp index 5033d4d87..030c94e48 100644 --- a/app/render/previewautocacher.cpp +++ b/app/render/previewautocacher.cpp @@ -98,7 +98,7 @@ void PreviewAutoCacher::NodeGraphChanged(NodeInput *source) connect(source, &NodeInput::destroyed, this, &PreviewAutoCacher::QueuedInputRemoved); } -void PreviewAutoCacher::GenerateHashes(ViewerOutput *viewer, const QVector ×, qint64 job_time) +void PreviewAutoCacher::GenerateHashes(ViewerOutput *viewer, FrameHashCache* cache, const QVector ×, qint64 job_time) { std::vector existing_hashes; @@ -110,7 +110,7 @@ void PreviewAutoCacher::GenerateHashes(ViewerOutput *viewer, const QVectorvideo_frame_cache()->CachePathName(hash)); + hash_exists = QFileInfo::exists(cache->CachePathName(hash)); if (hash_exists) { existing_hashes.push_back(hash); @@ -118,7 +118,7 @@ void PreviewAutoCacher::GenerateHashes(ViewerOutput *viewer, const QVectorvideo_frame_cache(), "SetHash", Qt::QueuedConnection, + QMetaObject::invokeMethod(cache, "SetHash", Qt::QueuedConnection, OLIVE_NS_ARG(rational, time), Q_ARG(QByteArray, hash), Q_ARG(qint64, job_time), @@ -128,8 +128,6 @@ void PreviewAutoCacher::GenerateHashes(ViewerOutput *viewer, const QVectorcancel(); + } + if (wait) { + for (auto it=copy.cbegin(); it!=copy.cend(); it++) { + it.key()->waitForFinished(); + } + } +} + void PreviewAutoCacher::CopyNodeInputValue(NodeInput *input) { // Find our copy of this parameter @@ -447,8 +476,6 @@ void PreviewAutoCacher::TryRender() } // No jobs are active, we can process the update queue - last_update_time_ = QDateTime::currentMSecsSinceEpoch(); - ProcessUpdateQueue(); if (video_params_changed_) { @@ -471,6 +498,7 @@ void PreviewAutoCacher::TryRender() connect(watcher, &QFutureWatcher::finished, this, &PreviewAutoCacher::HashesProcessed); watcher->setFuture(QtConcurrent::run(&PreviewAutoCacher::GenerateHashes, copied_viewer_node_, + viewer_node_->video_frame_cache(), frames, last_update_time_)); @@ -591,13 +619,7 @@ void PreviewAutoCacher::SetViewerNode(ViewerOutput *viewer_node) // We'll need to wait for these since they work directly on the FrameHashCache. Frames will // be in the cache for later use. - { - QMap*, QByteArray>::const_iterator i; - for (i=video_download_tasks_.constBegin(); i!=video_download_tasks_.constEnd(); i++) { - i.key()->waitForFinished(); - } - video_download_tasks_.clear(); - } + ClearVideoDownloadQueue(true); // No longer caching any hashes currently_caching_hashes_.clear(); diff --git a/app/render/previewautocacher.h b/app/render/previewautocacher.h index bd897bc69..b2ab2953a 100644 --- a/app/render/previewautocacher.h +++ b/app/render/previewautocacher.h @@ -81,6 +81,7 @@ public: void ClearHashQueue(bool wait = false); void ClearVideoQueue(bool wait = false); void ClearAudioQueue(bool wait = false); + void ClearVideoDownloadQueue(bool wait = false); public slots: /** @@ -89,7 +90,7 @@ public slots: void NodeGraphChanged(NodeInput *source); private: - static void GenerateHashes(ViewerOutput* viewer, const QVector& times, qint64 job_time); + static void GenerateHashes(ViewerOutput* viewer, FrameHashCache *cache, const QVector& times, qint64 job_time); void CopyNodeInputValue(NodeInput* input); Node *CopyNodeConnections(Node *src_node);