From 4f218522413b3f53e6ac8298f4cc26086a5dc263 Mon Sep 17 00:00:00 2001 From: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Wed, 9 Nov 2022 13:31:45 -0800 Subject: [PATCH] core: resolve all footage nodes in a project regardless of their connection to root --- app/core.cpp | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/app/core.cpp b/app/core.cpp index 4c01573bd..b66087d48 100644 --- a/app/core.cpp +++ b/app/core.cpp @@ -1713,38 +1713,39 @@ QString StripWindowsDriveLetter(QString s) bool Core::ValidateFootageInLoadedProject(Project* project, const QString& project_saved_url) { - QVector project_footage = project->root()->ListChildrenOfType(); QVector footage_we_couldnt_validate; - foreach (Footage* footage, project_footage) { - QString footage_fn = StripWindowsDriveLetter(footage->filename()); - QString project_fn = StripWindowsDriveLetter(project_saved_url); + for (Node *n : project->nodes()) { + if (Footage *footage = dynamic_cast(n)) { + QString footage_fn = StripWindowsDriveLetter(footage->filename()); + QString project_fn = StripWindowsDriveLetter(project_saved_url); - if (!QFileInfo::exists(footage_fn) && !project_saved_url.isEmpty()) { - // If the footage doesn't exist, it might have moved with the project - const QString& project_current_url = project->filename(); + if (!QFileInfo::exists(footage_fn) && !project_saved_url.isEmpty()) { + // If the footage doesn't exist, it might have moved with the project + const QString& project_current_url = project->filename(); - if (project_current_url != project_fn) { - // Project has definitely moved, try to resolve relative paths - QDir saved_dir(QFileInfo(project_fn).dir()); - QDir true_dir(QFileInfo(project_current_url).dir()); + if (project_current_url != project_fn) { + // Project has definitely moved, try to resolve relative paths + QDir saved_dir(QFileInfo(project_fn).dir()); + QDir true_dir(QFileInfo(project_current_url).dir()); - QString relative_filename = saved_dir.relativeFilePath(footage_fn); - QString transformed_abs_filename = true_dir.filePath(relative_filename); + QString relative_filename = saved_dir.relativeFilePath(footage_fn); + QString transformed_abs_filename = true_dir.filePath(relative_filename); - if (QFileInfo::exists(transformed_abs_filename)) { - // Use this file instead - qInfo() << "Resolved" << footage_fn << "relatively to" << transformed_abs_filename; - footage->set_filename(transformed_abs_filename); + if (QFileInfo::exists(transformed_abs_filename)) { + // Use this file instead + qInfo() << "Resolved" << footage_fn << "relatively to" << transformed_abs_filename; + footage->set_filename(transformed_abs_filename); + } } } - } - if (QFileInfo::exists(footage->filename())) { - // Assume valid - footage->SetValid(); - } else { - footage_we_couldnt_validate.append(footage); + if (QFileInfo::exists(footage->filename())) { + // Assume valid + footage->SetValid(); + } else { + footage_we_couldnt_validate.append(footage); + } } }