diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 0aaae93ea..75141c953 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -3450,6 +3450,7 @@ void MainWindow::PatternChangesWereSaved(bool saved) setWindowModified(state); not patternReadOnly ? ui->actionSave->setEnabled(state): ui->actionSave->setEnabled(false); isLayoutStale = true; + isNeedAutosave = not saved; } } @@ -3725,13 +3726,14 @@ bool MainWindow::SavePattern(const QString &fileName, QString &error) */ void MainWindow::AutoSavePattern() { - qCDebug(vMainWindow, "Autosaving pattern."); - - if (qApp->GetPatternPath().isEmpty() == false && this->isWindowModified() == true) + if (not qApp->GetPatternPath().isEmpty() && isWindowModified() && isNeedAutosave) { - QString autofile = qApp->GetPatternPath() + *autosavePrefix; + qCDebug(vMainWindow, "Autosaving pattern."); QString error; - SavePattern(autofile, error); + if (SavePattern(qApp->GetPatternPath() + *autosavePrefix, error)) + { + isNeedAutosave = false; + } } } diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp index 06301cf90..3a6e49e03 100644 --- a/src/app/valentina/mainwindowsnogui.cpp +++ b/src/app/valentina/mainwindowsnogui.cpp @@ -125,6 +125,7 @@ MainWindowsNoGUI::MainWindowsNoGUI(QWidget *parent) actionDockWidgetGroups(nullptr), isNoScaling(false), isLayoutStale(true), + isNeedAutosave(false), ignorePrinterFields(false), margins(), paperSize(), diff --git a/src/app/valentina/mainwindowsnogui.h b/src/app/valentina/mainwindowsnogui.h index d45ea5bbd..e9f6b6380 100644 --- a/src/app/valentina/mainwindowsnogui.h +++ b/src/app/valentina/mainwindowsnogui.h @@ -91,6 +91,7 @@ protected: bool isNoScaling; bool isLayoutStale; + bool isNeedAutosave; bool ignorePrinterFields; QMarginsF margins; QSizeF paperSize;