Fixed broken path to measurements after using Save As option.

--HG--
branch : release
This commit is contained in:
Roman Telezhynskyi 2016-02-09 16:16:04 +02:00
parent aee23cf700
commit 30adc76bce
3 changed files with 13 additions and 14 deletions

View File

@ -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".

View File

@ -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));

View File

@ -33,6 +33,7 @@
#include <QComboBox>
#include <QDir>
#include <QPrinterInfo>
#include <QDebug>
// Keep synchronize all names with initialization in VTranslateVars class!!!!!
//measurements
@ -1705,40 +1706,37 @@ 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())
if (QFileInfo(relativeMPath).isAbsolute())
{
qWarning() << QApplication::tr("The path to the measurments is already absolute.");
return relativeMPath;
}
return QFileInfo(QFileInfo(patternPath).absoluteDir(), relativeMPath).absoluteFilePath();
}
return QString();// should never reach
}
//---------------------------------------------------------------------------------------------------------------------
QSharedPointer<QPrinter> DefaultPrinter()
{