Fixed broken path to measurements after using Save As option.

(grafted from 2e63a19d717ad4ef5d6f38da7ed3b1ed6d7311a6)

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-02-09 17:19:19 +02:00
parent aa64076a36
commit 7deed94604
3 changed files with 13 additions and 14 deletions

View File

@ -6,6 +6,7 @@
- [#325] Check pattern for inverse compatibility.
# 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".

View File

@ -2985,7 +2985,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));

View File

@ -33,6 +33,7 @@
#include <QComboBox>
#include <QDir>
#include <QPrinterInfo>
#include <QDebug>
// Keep synchronize all names with initialization in VTranslateVars class!!!!!
//measurements
@ -1706,38 +1707,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();
}
//---------------------------------------------------------------------------------------------------------------------