From 7b13d3a5195cddf2d8a745d10f6305868cde46a5 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Thu, 26 Jan 2023 11:23:24 +0800 Subject: [PATCH] - enhancement: Pause autosave timer when autosave new files. --- NEWS.md | 1 + RedPandaIDE/mainwindow.cpp | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index 3b624147..edf44de9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 2706a65f..cefc045f 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -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);