From dcea610da2502f63f4b89b55f0b7f55d1b49ccd3 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 3 Jan 2019 20:50:56 +0200 Subject: [PATCH] Fix measurements path correction. After user finds new path to measurements file the path must be saved to pattern file automatically. But because of optimization we read file again and thus override the change. --HG-- branch : develop --- src/app/valentina/mainwindow.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index cd7b483d9..b725c5458 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -4590,12 +4590,13 @@ bool MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) qApp->setPatternUnit(doc->MUnit()); } const QString path = AbsoluteMPath(fileName, doc->MPath()); + QString fixedMPath; if (not path.isEmpty()) { // Check if exist - const QString newPath = CheckPathToMeasurements(fileName, path); - if (newPath.isEmpty()) + fixedMPath = CheckPathToMeasurements(fileName, path); + if (fixedMPath.isEmpty()) { qApp->setOpeningPattern();// End opening file Clear(); @@ -4608,11 +4609,11 @@ bool MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) return false; } - if (not LoadMeasurements(newPath)) + if (not LoadMeasurements(fixedMPath)) { qCCritical(vMainWindow, "%s", qUtf8Printable(tr("The measurements file '%1' could not be found or " "provides not enough information.") - .arg(newPath))); + .arg(fixedMPath))); qApp->setOpeningPattern();// End opening file Clear(); if (not VApplication::IsGUIMode()) @@ -4624,7 +4625,7 @@ bool MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) else { ui->actionUnloadMeasurements->setEnabled(true); - watcher->addPath(newPath); + watcher->addPath(fixedMPath); ui->actionEditCurrent->setEnabled(true); } } @@ -4645,6 +4646,10 @@ bool MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) { doc->SetMPath(RelativeMPath(fileName, customMeasureFile)); } + else if (not path.isEmpty() && fixedMPath != path) + { + doc->SetMPath(RelativeMPath(fileName, fixedMPath)); + } qApp->setPatternUnit(doc->MUnit()); } } @@ -4995,8 +5000,7 @@ QString MainWindow::CheckPathToMeasurements(const QString &patternPath, const QS if (usedNotExistedDir) { - QDir directory(dirPath); - directory.rmpath(QChar('.')); + QDir(dirPath).rmpath(QChar('.')); } return mPath; @@ -5109,7 +5113,6 @@ QString MainWindow::CheckPathToMeasurements(const QString &patternPath, const QS qApp->setPatternType(patternType); doc->SetMPath(RelativeMPath(patternPath, mPath)); - PatternChangesWereSaved(false); return mPath; } }