Optimizing calling autosave. It should be called only for new unsaved changes.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2018-11-24 19:34:59 +02:00
parent cf3be706c2
commit 9c2cdad1a8
3 changed files with 9 additions and 5 deletions

View File

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

View File

@ -125,6 +125,7 @@ MainWindowsNoGUI::MainWindowsNoGUI(QWidget *parent)
actionDockWidgetGroups(nullptr),
isNoScaling(false),
isLayoutStale(true),
isNeedAutosave(false),
ignorePrinterFields(false),
margins(),
paperSize(),

View File

@ -91,6 +91,7 @@ protected:
bool isNoScaling;
bool isLayoutStale;
bool isNeedAutosave;
bool ignorePrinterFields;
QMarginsF margins;
QSizeF paperSize;