diff --git a/app/node/project/project.cpp b/app/node/project/project.cpp index d16c78d94..faae9c903 100644 --- a/app/node/project/project.cpp +++ b/app/node/project/project.cpp @@ -220,16 +220,6 @@ void Project::set_filename(const QString &s) emit NameChanged(); } -ColorManager *Project::color_manager() -{ - return color_manager_; -} - -bool Project::is_modified() const -{ - return is_modified_; -} - void Project::set_modified(bool e) { is_modified_ = e; diff --git a/app/node/project/project.h b/app/node/project/project.h index 415307569..5d1471d6f 100644 --- a/app/node/project/project.h +++ b/app/node/project/project.h @@ -62,9 +62,10 @@ public: QString pretty_filename() const; void set_filename(const QString& s); - ColorManager* color_manager(); + ColorManager* color_manager() { return color_manager_; } + ProjectSettingsNode* settings() { return settings_; } - bool is_modified() const; + bool is_modified() const { return is_modified_; } void set_modified(bool e); bool has_autorecovery_been_saved() const; diff --git a/app/task/precache/precachetask.cpp b/app/task/precache/precachetask.cpp index 28d08954e..703298889 100644 --- a/app/task/precache/precachetask.cpp +++ b/app/task/precache/precachetask.cpp @@ -27,23 +27,31 @@ namespace olive { PreCacheTask::PreCacheTask(Footage *footage, int index, Sequence* sequence) : RenderTask(new ViewerOutput(), sequence->GetVideoParams(), sequence->GetAudioParams()) { + // Create new project + project_ = new Project(); + + // Create viewer with same parameters as the sequence + viewer()->setParent(project_); viewer()->SetVideoParams(sequence->GetVideoParams()); viewer()->SetAudioParams(sequence->GetAudioParams()); + // Copy project config nodes + Node::CopyInputs(footage->project()->color_manager(), project_->color_manager(), false); + Node::CopyInputs(footage->project()->settings(), project_->settings(), false); + // Copy footage node so it can precache without any modifications from the user screwing it up footage_ = static_cast(footage->copy()); - index_ = index; + footage_->setParent(project_); Node::CopyInputs(footage, footage_, false); + Node::ConnectEdge(NodeOutput(footage_, Track::Reference(Track::kVideo, index).ToString()), NodeInput(viewer(), ViewerOutput::kTextureInput)); - Node::ConnectEdge(NodeOutput(footage_, Track::Reference(Track::kVideo, 0).ToString()), NodeInput(viewer(), ViewerOutput::kTextureInput)); - - SetTitle(tr("Pre-caching %1:%2").arg(footage_->filename())); + SetTitle(tr("Pre-caching %1:%2").arg(footage_->filename(), index)); } PreCacheTask::~PreCacheTask() { - // We created this viewer node ourselves, so now we should delete it - delete viewer(); + // This should delete the footage we copied and the viewer we created + delete project_; } bool PreCacheTask::Run() diff --git a/app/task/precache/precachetask.h b/app/task/precache/precachetask.h index bcf1358e9..96d31d1a7 100644 --- a/app/task/precache/precachetask.h +++ b/app/task/precache/precachetask.h @@ -43,9 +43,9 @@ protected: virtual void AudioDownloaded(const TimeRange& range, SampleBufferPtr samples, qint64 job_time) override; private: - Footage* footage_; + Project* project_; - int index_; + Footage* footage_; }; diff --git a/app/widget/projectexplorer/projectexplorer.cpp b/app/widget/projectexplorer/projectexplorer.cpp index c5f23b965..3c870caba 100644 --- a/app/widget/projectexplorer/projectexplorer.cpp +++ b/app/widget/projectexplorer/projectexplorer.cpp @@ -490,15 +490,19 @@ void ProjectExplorer::ContextMenuStartProxy(QAction *a) Sequence* sequence = Node::ValueToPtr(a->data()); // To get here, the `context_menu_items_` must be all kFootage - foreach (Node* i, context_menu_items_) { - Footage* f = static_cast(i); + foreach (Node* item, context_menu_items_) { + Footage* f = static_cast(item); - QVector enabled_streams = f->GetEnabledVideoStreams(); + int sz = f->InputArraySize(Footage::kVideoParamsInput); - foreach (const VideoParams& stream, enabled_streams) { - // Start a background task for proxying - PreCacheTask* proxy_task = new PreCacheTask(f, stream.stream_index(), sequence); - TaskManager::instance()->AddTask(proxy_task); + for (int j=0; jGetVideoParams(j); + + if (vp.enabled()) { + // Start a background task for proxying + PreCacheTask* proxy_task = new PreCacheTask(f, j, sequence); + TaskManager::instance()->AddTask(proxy_task); + } } } }