From 131941801ddb89aa89e36a04a01a989c0370b5ad Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Fri, 3 May 2024 08:48:58 +0800 Subject: [PATCH] simplify implementation --- RedPandaIDE/parser/cppparser.cpp | 14 ++++++-------- RedPandaIDE/parser/cppparser.h | 4 ++-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index e53cf237..ab44b663 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -989,7 +989,7 @@ bool CppParser::isSystemHeaderFile(const QString &fileName) return ::isSystemHeaderFile(fileName,mPreprocessor.includePaths()); } -void CppParser::parseFile(const QString &fileName, bool inProject, bool onlyIfNotParsed, bool updateView, std::weak_ptr parserPtr) +void CppParser::parseFile(const QString &fileName, bool inProject, bool onlyIfNotParsed, bool updateView, std::shared_ptr parserPtr) { if (!mEnabled) return; @@ -1021,13 +1021,11 @@ void CppParser::parseFile(const QString &fileName, bool inProject, bool onlyIfNo emit onEndParsing(mFilesScannedCount,0); if (mLastParseFileCommand) { - PCppParser parser=mLastParseFileCommand->parserPtr.lock(); - if (parser) - ::parseFile(parser, - mLastParseFileCommand->fileName, - mLastParseFileCommand->inProject, - mLastParseFileCommand->onlyIfNotParsed, - mLastParseFileCommand->updateView); + ::parseFile(mLastParseFileCommand->parserPtr, + mLastParseFileCommand->fileName, + mLastParseFileCommand->inProject, + mLastParseFileCommand->onlyIfNotParsed, + mLastParseFileCommand->updateView); mLastParseFileCommand = nullptr; } mParsing = false; diff --git a/RedPandaIDE/parser/cppparser.h b/RedPandaIDE/parser/cppparser.h index 64bc9cc2..91c99fa4 100644 --- a/RedPandaIDE/parser/cppparser.h +++ b/RedPandaIDE/parser/cppparser.h @@ -36,7 +36,7 @@ public: bool inProject; bool onlyIfNotParsed; bool updateView; - std::weak_ptr parserPtr; + std::shared_ptr parserPtr; }; using PParseFileCommand = std::unique_ptr; @@ -121,7 +121,7 @@ public: bool isSystemHeaderFile(const QString& fileName); void parseFile(const QString& fileName, bool inProject, bool onlyIfNotParsed = false, bool updateView = true, - std::weak_ptr parserPtr = std::weak_ptr{}); + std::shared_ptr parserPtr = nullptr); void parseFileList(bool updateView = true); void parseHardDefines(); bool parsing() const;