From 640202da5fbc2631b5a5f089bbe16b1c20911af9 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 23 Sep 2015 13:11:19 +0300 Subject: [PATCH] Pass correct path to measurements in a pattern file. --HG-- branch : develop --- src/app/valentina/main.cpp | 2 +- src/app/valentina/mainwindow.cpp | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/app/valentina/main.cpp b/src/app/valentina/main.cpp index 8ecde4a33..a39f35be2 100644 --- a/src/app/valentina/main.cpp +++ b/src/app/valentina/main.cpp @@ -69,7 +69,7 @@ int main(int argc, char *argv[]) for (size_t i=0, sz = args.size(); i < sz;++i) { - bool loaded = w.LoadPattern(args.at(static_cast(i)), app.CommandLine()->OptMeasurePath()); + const bool loaded = w.LoadPattern(args.at(static_cast(i)), app.CommandLine()->OptMeasurePath()); if (app.CommandLine()->IsExportEnabled()) { if (loaded) diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index d74cb505d..87e493d85 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -341,7 +341,7 @@ QString MainWindow::RelativeMPath(const QString &patternPath, const QString &abs return absoluteMPath; } - if (absoluteMPath.isEmpty()) + if (absoluteMPath.isEmpty() || QFileInfo(absoluteMPath).isRelative()) { return absoluteMPath; } @@ -359,6 +359,11 @@ QString MainWindow::AbsoluteMPath(const QString &patternPath, const QString &rel } else { + if (QFileInfo(relativeMPath).isAbsolute()) + { + return relativeMPath; + } + return QFileInfo(QFileInfo(patternPath).absoluteDir(), relativeMPath).absoluteFilePath(); } } @@ -3159,15 +3164,15 @@ bool MainWindow::LoadPattern(const QString &fileName, const QString& customMeasu doc->setXMLContent(fileName); if (!customMeasureFile.isEmpty()) { - doc->SetPath(customMeasureFile); + doc->SetPath(RelativeMPath(fileName, customMeasureFile)); } qApp->setPatternUnit(doc->MUnit()); - QString path = doc->MPath(); + QString path = AbsoluteMPath(fileName, doc->MPath()); if (not path.isEmpty()) { // Check if exist - path = CheckPathToMeasurements(fileName, AbsoluteMPath(fileName, path)); + path = CheckPathToMeasurements(fileName, path); if (path.isEmpty()) { Clear();