Pass correct path to measurements in a pattern file.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-09-23 13:11:19 +03:00
parent 1cbc5195c2
commit 640202da5f
2 changed files with 10 additions and 5 deletions

View File

@ -69,7 +69,7 @@ int main(int argc, char *argv[])
for (size_t i=0, sz = args.size(); i < sz;++i) for (size_t i=0, sz = args.size(); i < sz;++i)
{ {
bool loaded = w.LoadPattern(args.at(static_cast<int>(i)), app.CommandLine()->OptMeasurePath()); const bool loaded = w.LoadPattern(args.at(static_cast<int>(i)), app.CommandLine()->OptMeasurePath());
if (app.CommandLine()->IsExportEnabled()) if (app.CommandLine()->IsExportEnabled())
{ {
if (loaded) if (loaded)

View File

@ -341,7 +341,7 @@ QString MainWindow::RelativeMPath(const QString &patternPath, const QString &abs
return absoluteMPath; return absoluteMPath;
} }
if (absoluteMPath.isEmpty()) if (absoluteMPath.isEmpty() || QFileInfo(absoluteMPath).isRelative())
{ {
return absoluteMPath; return absoluteMPath;
} }
@ -359,6 +359,11 @@ QString MainWindow::AbsoluteMPath(const QString &patternPath, const QString &rel
} }
else else
{ {
if (QFileInfo(relativeMPath).isAbsolute())
{
return relativeMPath;
}
return QFileInfo(QFileInfo(patternPath).absoluteDir(), relativeMPath).absoluteFilePath(); return QFileInfo(QFileInfo(patternPath).absoluteDir(), relativeMPath).absoluteFilePath();
} }
} }
@ -3159,15 +3164,15 @@ bool MainWindow::LoadPattern(const QString &fileName, const QString& customMeasu
doc->setXMLContent(fileName); doc->setXMLContent(fileName);
if (!customMeasureFile.isEmpty()) if (!customMeasureFile.isEmpty())
{ {
doc->SetPath(customMeasureFile); doc->SetPath(RelativeMPath(fileName, customMeasureFile));
} }
qApp->setPatternUnit(doc->MUnit()); qApp->setPatternUnit(doc->MUnit());
QString path = doc->MPath(); QString path = AbsoluteMPath(fileName, doc->MPath());
if (not path.isEmpty()) if (not path.isEmpty())
{ {
// Check if exist // Check if exist
path = CheckPathToMeasurements(fileName, AbsoluteMPath(fileName, path)); path = CheckPathToMeasurements(fileName, path);
if (path.isEmpty()) if (path.isEmpty())
{ {
Clear(); Clear();