- enhancement: Waiting for syntax parsers to finish before saving files, to prevent data lost caused by syntax parsering crash.

This commit is contained in:
Roy Qu 2023-01-03 21:43:45 +08:00
parent 375e990e0b
commit 562293c05d
4 changed files with 31 additions and 4 deletions

View File

@ -10,6 +10,7 @@ Red Panda C++ Version 2.8
- enhancement: "Switch Header/Source" in editor title bar context menu.
- enhancement: "Toggle readonly" in the Edit menu.
- fix: Error When save project units' encoding settings.
- enhancement: Waiting for syntax parsers to finish before saving files, to prevent data lost caused by syntax parsering crash.
Red Panda C++ Version 2.7

View File

@ -260,6 +260,9 @@ bool Editor::save(bool force, bool doReparse) {
if (this->mIsNew && !force) {
return saveAs();
}
while (pMainWindow->parsing()) {
QThread::msleep(200);
}
//is this file writable;
pMainWindow->fileSystemWatcher()->removePath(mFilename);
try {

View File

@ -519,6 +519,9 @@ void MainWindow::updateEditorActions()
void MainWindow::updateEditorActions(const Editor *e)
{
//it's not a compile action, but put here for convinience
ui->actionSaveAll->setEnabled(
(mProject!=nullptr || mEditorList->pageCount()>0));
if (e==nullptr) {
ui->actionAuto_Detect->setEnabled(false);
ui->actionEncode_in_ANSI->setEnabled(false);
@ -659,7 +662,9 @@ void MainWindow::updateCompileActions() {
void MainWindow::updateCompileActions(const Editor *e)
{
if (mCompilerManager->compiling() || mCompilerManager->running() || mDebugger->executing()) {
if (mCompilerManager->compiling()
//|| mCompilerManager->backgroundSyntaxChecking()
|| mCompilerManager->running() || mDebugger->executing()) {
ui->actionCompile->setEnabled(false);
ui->actionCompile_Run->setEnabled(false);
ui->actionRun->setEnabled(false);
@ -712,9 +717,7 @@ void MainWindow::updateCompileActions(const Editor *e)
}
ui->actionStop_Execution->setEnabled(mCompilerManager->running() || mDebugger->executing());
//it's not a compile action, but put here for convinience
ui->actionSaveAll->setEnabled(mProject!=nullptr
|| mEditorList->pageCount()>0);
}
void MainWindow::updateEditorColorSchemes()
@ -1850,6 +1853,24 @@ void MainWindow::checkSyntaxInBack(Editor *e)
}
}
bool MainWindow::compiling()
{
return (mCompilerManager->backgroundSyntaxChecking()) || (mCompilerManager->compiling());
}
bool MainWindow::parsing()
{
if (mProject && mProject->cppParser() && mProject->cppParser()->parsing())
return true;
for(int i=0;i<mEditorList->pageCount();i++) {
Editor * editor = (*mEditorList)[i];
if (editor->parser() && editor->parser()->parsing())
return true;
}
return false;
}
bool MainWindow::compile(bool rebuild, CppCompileType compileType)
{
mCompilerManager->stopPausing();

View File

@ -131,6 +131,8 @@ public:
void updateDebuggerSettings();
void updateActionIcons();
void checkSyntaxInBack(Editor* e);
bool compiling();
bool parsing();
bool compile(bool rebuild=false, CppCompileType compileType=CppCompileType::Normal);
void runExecutable(
const QString& exeName,