diff -r 8d88adffb779 -r 16f6717a218b src/documentmanager.cpp --- a/src/documentmanager.cpp Wed Apr 12 01:53:42 2023 +0300 +++ b/src/documentmanager.cpp Wed Apr 19 22:42:43 2023 +0300 @@ -341,7 +341,7 @@ } } -static QString findFile( +static QFileInfo findFile( QString referenceName, const QString& modelPath, const LibrariesModel& libraries) @@ -349,8 +349,8 @@ // Try to find the file in the same place as the model itself referenceName.replace("\\", "/"); const QDir dir = QFileInfo{modelPath}.dir(); - QString referencedFilePath = dir.filePath(referenceName); - if (not QFileInfo{referencedFilePath}.exists()) + QFileInfo referencedFilePath = {dir.filePath(referenceName)}; + if (not referencedFilePath.exists()) { // Look for it in the libraries referencedFilePath = libraries.findFile(referenceName); @@ -373,14 +373,14 @@ struct Dependency { QString name; - QString path; + QFileInfo path; bool operator<(const Dependency& other) const { if (this->name != other.name) { return this->name < other.name; } else { - return this->path < other.path; + return this->path.absoluteFilePath() < other.path.absoluteFilePath(); } } }; @@ -393,8 +393,9 @@ const std::set refNames = referenceNames(modelInfo->model.get()); if (modelInfo != nullptr) { for (const QString& name : refNames) { - const QString path = findFile(name, modelInfo->path, *libraries); - if (not path.isEmpty()) { + const QFileInfo path = findFile(name, modelInfo->path, *libraries); + if (path.exists()) + { result.insert(Dependency{.name = name, .path = path}); } } @@ -419,17 +420,17 @@ if (idp != nullptr) { info->dependencies[dep.name] = *idp; } - else if (not info->dependencies.contains(dep.name) and not missing.contains(dep.path)) { + else if (not info->dependencies.contains(dep.name) and not missing.contains(dep.path.absoluteFilePath())) { QString loadErrorString; QTextStream localErrorStream{&loadErrorString}; const std::optional modelIdOpt = documents->openModel( - dep.path, + dep.path.absoluteFilePath(), localErrorStream, OpenType::AutomaticallyOpened); if (not modelIdOpt.has_value()) { const QString& errorMessage = QObject::tr("could not load '%1': %2") - .arg(dep.path, loadErrorString); - missing[dep.path] = errorMessage; + .arg(dep.path.absoluteFilePath(), loadErrorString); + missing[dep.path.absoluteFilePath()] = errorMessage; } else { info->dependencies[dep.name] = modelIdOpt.value();