- enhancement: Pause autosave timer when autosave new files.

This commit is contained in:
Roy Qu 2023-01-26 11:23:24 +08:00
parent 629a90d521
commit 7b13d3a519
2 changed files with 9 additions and 2 deletions

View File

@ -19,6 +19,7 @@ Red Panda C++ Version 2.10
- fix: Can't correctly set project file's encoding back to 'UTF-8'/'ANSI' in the project options dialog/files setting page.
- enhancement: Simplified chinese translations for encoding names.
- fix: Crash when there are preprocessing directives like '#if 0/0' or '#if 0%0'
- enhancement: Pause autosave timer when autosave new files.
Red Panda C++ Version 2.9

View File

@ -2421,7 +2421,6 @@ void MainWindow::prepareDebugger()
void MainWindow::doAutoSave(Editor *e)
{
if (!e || !e->canAutoSave())
return;
QString filename = e->filename();
@ -2432,7 +2431,12 @@ void MainWindow::doAutoSave(Editor *e)
QString suffix = fileInfo.suffix();
switch(pSettings->editor().autoSaveStrategy()) {
case assOverwrite:
e->save();
if (e->isNew()) {
mAutoSaveTimer.stop();
e->save();
mAutoSaveTimer.start(pSettings->editor().autoSaveInterval()*60*1000);
} else
e->save();
return;
case assAppendUnixTimestamp:
filename = parent.filePath(
@ -2451,7 +2455,9 @@ void MainWindow::doAutoSave(Editor *e)
}
}
if (e->isNew()) {
mAutoSaveTimer.stop();
e->saveAs();
mAutoSaveTimer.start(pSettings->editor().autoSaveInterval()*60*1000);
} else {
e->saveFile(filename);
e->setCanAutoSave(false);