From b958cdc00c6c859f476551a744c05b5f156786f3 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Mon, 24 Oct 2022 22:53:46 +0800 Subject: [PATCH] - enhancement: when closing project, prevent all editors that belongs to the project check syntax and parse todos. --- NEWS.md | 1 + RedPandaIDE/editor.cpp | 8 +++++--- RedPandaIDE/mainwindow.cpp | 8 ++++++++ RedPandaIDE/mainwindow.h | 2 ++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index c83d8e0b..e6dd4766 100644 --- a/NEWS.md +++ b/NEWS.md @@ -21,6 +21,7 @@ Red Panda C++ Version 2.0 - enhancement: separate compiler's language standard option for C / C++ - fix: compiler settings not correctly handled when create makefile - enhancement: auto locate current open file in the project view panel + - enhancement: when closing project, prevent all editors that belongs to the project check syntax and parse todos. Red Panda C++ Version 1.5 diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index d36b7e59..0c5adadf 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -1289,8 +1289,10 @@ void Editor::showEvent(QShowEvent */*event*/) // } if (!pMainWindow->isClosingAll() && !pMainWindow->isQuitting()) { - checkSyntaxInBack(); - reparseTodo(); + if (!inProject() || !pMainWindow->closingProject()) { + checkSyntaxInBack(); + reparseTodo(); + } } pMainWindow->updateClassBrowserForEditor(this); pMainWindow->updateAppTitle(this); @@ -1298,7 +1300,7 @@ void Editor::showEvent(QShowEvent */*event*/) pMainWindow->updateForEncodingInfo(this); pMainWindow->updateStatusbarForLineCol(this); pMainWindow->updateForStatusbarModeInfo(this); - if (inProject()) { + if (inProject() && !pMainWindow->closingProject()) { pMainWindow->setProjectCurrentFile(mFilename); } diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 2f9cf3de..92fc154b 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -109,6 +109,7 @@ MainWindow::MainWindow(QWidget *parent) ui(new Ui::MainWindow), mSearchDialog(nullptr), mQuitting(false), + mClosingProject(false), mCheckSyntaxInBack(false), mShouldRemoveAllSettings(false), mClosing(false), @@ -4602,6 +4603,7 @@ void MainWindow::closeProject(bool refreshEditor) } else mProject->saveLayout(); // always save layout, but not when SaveAll has been called + mClosingProject=true; mBookmarkModel->saveProjectBookmarks( changeFileExt(mProject->filename(), PROJECT_BOOKMARKS_EXT), mProject->directory()); @@ -4640,6 +4642,7 @@ void MainWindow::closeProject(bool refreshEditor) clearIssues(); updateProjectView(); } + mClosingProject=false; } } @@ -8581,6 +8584,11 @@ void MainWindow::on_actionNew_Template_triggered() } } +bool MainWindow::closingProject() const +{ + return mClosingProject; +} + const std::shared_ptr &MainWindow::visitHistoryManager() const { return mVisitHistoryManager; diff --git a/RedPandaIDE/mainwindow.h b/RedPandaIDE/mainwindow.h index 274902f8..d1e52071 100644 --- a/RedPandaIDE/mainwindow.h +++ b/RedPandaIDE/mainwindow.h @@ -746,6 +746,7 @@ private: CPUDialog *mCPUDialog; SearchDialog *mSearchDialog; bool mQuitting; + bool mClosingProject; QElapsedTimer mParserTimer; QFileSystemWatcher mFileSystemWatcher; std::shared_ptr mProject; @@ -880,6 +881,7 @@ public: bool isClosingAll() const; bool isQuitting() const; const std::shared_ptr &visitHistoryManager() const; + bool closingProject() const; }; extern MainWindow* pMainWindow;