diff --git a/io/loadthread.cpp b/io/loadthread.cpp index 281841763..4422353fb 100644 --- a/io/loadthread.cpp +++ b/io/loadthread.cpp @@ -201,15 +201,25 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) { f->url = attr.value().toString(); if (!QFileInfo::exists(f->url)) { // if path is not absolute + // tries to locate file using a file path relative to the project's current folder QString proj_dir_test = proj_dir.absoluteFilePath(f->url); + + // tries to locate file using a file path relative to the folder the project was saved in + // (unaffected by moving the project file) QString internal_proj_dir_test = internal_proj_dir.absoluteFilePath(f->url); + // tries to locate file using the file name directly in the project's current folder + QString proj_dir_direct_test = proj_dir.filePath(QFileInfo(f->url).fileName()); + if (QFileInfo::exists(proj_dir_test)) { // if path is relative to the project's current dir f->url = proj_dir_test; qInfo() << "Matched" << attr.value().toString() << "relative to project's current directory"; } else if (QFileInfo::exists(internal_proj_dir_test)) { // if path is relative to the last directory the project was saved in f->url = internal_proj_dir_test; qInfo() << "Matched" << attr.value().toString() << "relative to project's internal directory"; + } else if (QFileInfo::exists(proj_dir_direct_test)) + f->url = proj_dir_direct_test; + qInfo() << "Matched" << attr.value().toString() << "directly to project's current directory"; } else if (f->url.contains('%')) { // hack for image sequences (qt won't be able to find the URL with %, but ffmpeg may) f->url = internal_proj_dir_test;