simplify implementation

This commit is contained in:
Roy Qu 2024-05-03 08:48:58 +08:00
parent 68209fe619
commit 131941801d
2 changed files with 8 additions and 10 deletions

View File

@ -989,7 +989,7 @@ bool CppParser::isSystemHeaderFile(const QString &fileName)
return ::isSystemHeaderFile(fileName,mPreprocessor.includePaths()); return ::isSystemHeaderFile(fileName,mPreprocessor.includePaths());
} }
void CppParser::parseFile(const QString &fileName, bool inProject, bool onlyIfNotParsed, bool updateView, std::weak_ptr<CppParser> parserPtr) void CppParser::parseFile(const QString &fileName, bool inProject, bool onlyIfNotParsed, bool updateView, std::shared_ptr<CppParser> parserPtr)
{ {
if (!mEnabled) if (!mEnabled)
return; return;
@ -1021,13 +1021,11 @@ void CppParser::parseFile(const QString &fileName, bool inProject, bool onlyIfNo
emit onEndParsing(mFilesScannedCount,0); emit onEndParsing(mFilesScannedCount,0);
if (mLastParseFileCommand) { if (mLastParseFileCommand) {
PCppParser parser=mLastParseFileCommand->parserPtr.lock(); ::parseFile(mLastParseFileCommand->parserPtr,
if (parser) mLastParseFileCommand->fileName,
::parseFile(parser, mLastParseFileCommand->inProject,
mLastParseFileCommand->fileName, mLastParseFileCommand->onlyIfNotParsed,
mLastParseFileCommand->inProject, mLastParseFileCommand->updateView);
mLastParseFileCommand->onlyIfNotParsed,
mLastParseFileCommand->updateView);
mLastParseFileCommand = nullptr; mLastParseFileCommand = nullptr;
} }
mParsing = false; mParsing = false;

View File

@ -36,7 +36,7 @@ public:
bool inProject; bool inProject;
bool onlyIfNotParsed; bool onlyIfNotParsed;
bool updateView; bool updateView;
std::weak_ptr<CppParser> parserPtr; std::shared_ptr<CppParser> parserPtr;
}; };
using PParseFileCommand = std::unique_ptr<ParseFileCommand>; using PParseFileCommand = std::unique_ptr<ParseFileCommand>;
@ -121,7 +121,7 @@ public:
bool isSystemHeaderFile(const QString& fileName); bool isSystemHeaderFile(const QString& fileName);
void parseFile(const QString& fileName, bool inProject, void parseFile(const QString& fileName, bool inProject,
bool onlyIfNotParsed = false, bool updateView = true, bool onlyIfNotParsed = false, bool updateView = true,
std::weak_ptr<CppParser> parserPtr = std::weak_ptr<CppParser>{}); std::shared_ptr<CppParser> parserPtr = nullptr);
void parseFileList(bool updateView = true); void parseFileList(bool updateView = true);
void parseHardDefines(); void parseHardDefines();
bool parsing() const; bool parsing() const;