- enhancement: when closing project, prevent all editors that belongs to the project check syntax and parse todos.

This commit is contained in:
Roy Qu 2022-10-24 22:53:46 +08:00
parent f20a979885
commit b958cdc00c
4 changed files with 16 additions and 3 deletions

View File

@ -21,6 +21,7 @@ Red Panda C++ Version 2.0
- enhancement: separate compiler's language standard option for C / C++ - enhancement: separate compiler's language standard option for C / C++
- fix: compiler settings not correctly handled when create makefile - fix: compiler settings not correctly handled when create makefile
- enhancement: auto locate current open file in the project view panel - 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 Red Panda C++ Version 1.5

View File

@ -1289,8 +1289,10 @@ void Editor::showEvent(QShowEvent */*event*/)
// } // }
if (!pMainWindow->isClosingAll() if (!pMainWindow->isClosingAll()
&& !pMainWindow->isQuitting()) { && !pMainWindow->isQuitting()) {
checkSyntaxInBack(); if (!inProject() || !pMainWindow->closingProject()) {
reparseTodo(); checkSyntaxInBack();
reparseTodo();
}
} }
pMainWindow->updateClassBrowserForEditor(this); pMainWindow->updateClassBrowserForEditor(this);
pMainWindow->updateAppTitle(this); pMainWindow->updateAppTitle(this);
@ -1298,7 +1300,7 @@ void Editor::showEvent(QShowEvent */*event*/)
pMainWindow->updateForEncodingInfo(this); pMainWindow->updateForEncodingInfo(this);
pMainWindow->updateStatusbarForLineCol(this); pMainWindow->updateStatusbarForLineCol(this);
pMainWindow->updateForStatusbarModeInfo(this); pMainWindow->updateForStatusbarModeInfo(this);
if (inProject()) { if (inProject() && !pMainWindow->closingProject()) {
pMainWindow->setProjectCurrentFile(mFilename); pMainWindow->setProjectCurrentFile(mFilename);
} }

View File

@ -109,6 +109,7 @@ MainWindow::MainWindow(QWidget *parent)
ui(new Ui::MainWindow), ui(new Ui::MainWindow),
mSearchDialog(nullptr), mSearchDialog(nullptr),
mQuitting(false), mQuitting(false),
mClosingProject(false),
mCheckSyntaxInBack(false), mCheckSyntaxInBack(false),
mShouldRemoveAllSettings(false), mShouldRemoveAllSettings(false),
mClosing(false), mClosing(false),
@ -4602,6 +4603,7 @@ void MainWindow::closeProject(bool refreshEditor)
} else } else
mProject->saveLayout(); // always save layout, but not when SaveAll has been called mProject->saveLayout(); // always save layout, but not when SaveAll has been called
mClosingProject=true;
mBookmarkModel->saveProjectBookmarks( mBookmarkModel->saveProjectBookmarks(
changeFileExt(mProject->filename(), PROJECT_BOOKMARKS_EXT), changeFileExt(mProject->filename(), PROJECT_BOOKMARKS_EXT),
mProject->directory()); mProject->directory());
@ -4640,6 +4642,7 @@ void MainWindow::closeProject(bool refreshEditor)
clearIssues(); clearIssues();
updateProjectView(); updateProjectView();
} }
mClosingProject=false;
} }
} }
@ -8581,6 +8584,11 @@ void MainWindow::on_actionNew_Template_triggered()
} }
} }
bool MainWindow::closingProject() const
{
return mClosingProject;
}
const std::shared_ptr<VisitHistoryManager> &MainWindow::visitHistoryManager() const const std::shared_ptr<VisitHistoryManager> &MainWindow::visitHistoryManager() const
{ {
return mVisitHistoryManager; return mVisitHistoryManager;

View File

@ -746,6 +746,7 @@ private:
CPUDialog *mCPUDialog; CPUDialog *mCPUDialog;
SearchDialog *mSearchDialog; SearchDialog *mSearchDialog;
bool mQuitting; bool mQuitting;
bool mClosingProject;
QElapsedTimer mParserTimer; QElapsedTimer mParserTimer;
QFileSystemWatcher mFileSystemWatcher; QFileSystemWatcher mFileSystemWatcher;
std::shared_ptr<Project> mProject; std::shared_ptr<Project> mProject;
@ -880,6 +881,7 @@ public:
bool isClosingAll() const; bool isClosingAll() const;
bool isQuitting() const; bool isQuitting() const;
const std::shared_ptr<VisitHistoryManager> &visitHistoryManager() const; const std::shared_ptr<VisitHistoryManager> &visitHistoryManager() const;
bool closingProject() const;
}; };
extern MainWindow* pMainWindow; extern MainWindow* pMainWindow;