From 30adc76bce693253243c0b276f55a08f69abcbb8 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 9 Feb 2016 16:16:04 +0200 Subject: [PATCH] Fixed broken path to measurements after using Save As option. --HG-- branch : release --- ChangeLog.txt | 1 + src/app/valentina/mainwindow.cpp | 2 +- src/libs/vmisc/def.cpp | 24 +++++++++++------------- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 7b88a3d21..d0c03dc5c 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,4 +1,5 @@ # Version 0.4.2 +- Fixed broken path to measurements after using Save As option. - Tool line. Block selecting the same point twice. - [#443] Not valid dxf file. libdxf updated to version 3.12.2.0. Fixed drawing subpaths. - Fixed combobox width in Dialog "Tool True Dart point". diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 97eafe4ea..852a3a3bf 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -2929,7 +2929,7 @@ bool MainWindow::SavePattern(const QString &fileName, QString &error) qCDebug(vMainWindow, "Saving pattern file %s.", qUtf8Printable(fileName)); QFileInfo tempInfo(fileName); - const QString mPath = doc->MPath(); + const QString mPath = AbsoluteMPath(curFile, doc->MPath()); if (not mPath.isEmpty() && curFile != fileName) { doc->SetPath(RelativeMPath(fileName, mPath)); diff --git a/src/libs/vmisc/def.cpp b/src/libs/vmisc/def.cpp index 23883173c..7ae5c44b3 100644 --- a/src/libs/vmisc/def.cpp +++ b/src/libs/vmisc/def.cpp @@ -33,6 +33,7 @@ #include #include #include +#include // Keep synchronize all names with initialization in VTranslateVars class!!!!! //measurements @@ -1705,38 +1706,35 @@ QString StrippedName(const QString &fullFileName) //--------------------------------------------------------------------------------------------------------------------- QString RelativeMPath(const QString &patternPath, const QString &absoluteMPath) { - if (patternPath.isEmpty()) + if (patternPath.isEmpty() || absoluteMPath.isEmpty()) { return absoluteMPath; } - if (absoluteMPath.isEmpty() || QFileInfo(absoluteMPath).isRelative()) + if (QFileInfo(absoluteMPath).isRelative()) { + qWarning() << QApplication::tr("The path to the measurments is already relative."); return absoluteMPath; } - QDir dir(QFileInfo(patternPath).absoluteDir()); - return dir.relativeFilePath(absoluteMPath); + return QFileInfo(patternPath).absoluteDir().relativeFilePath(absoluteMPath); } //--------------------------------------------------------------------------------------------------------------------- QString AbsoluteMPath(const QString &patternPath, const QString &relativeMPath) { - if (patternPath.isEmpty()) + if (patternPath.isEmpty() || relativeMPath.isEmpty()) { return relativeMPath; } - else - { - if (relativeMPath.isEmpty() || QFileInfo(relativeMPath).isAbsolute()) - { - return relativeMPath; - } - return QFileInfo(QFileInfo(patternPath).absoluteDir(), relativeMPath).absoluteFilePath(); + if (QFileInfo(relativeMPath).isAbsolute()) + { + qWarning() << QApplication::tr("The path to the measurments is already absolute."); + return relativeMPath; } - return QString();// should never reach + return QFileInfo(QFileInfo(patternPath).absoluteDir(), relativeMPath).absoluteFilePath(); } //---------------------------------------------------------------------------------------------------------------------