fix: (UB) get shared ptr from raw pointer
This commit is contained in:
parent
2b029bc4cb
commit
1eb804ab0e
|
@ -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)
|
void CppParser::parseFile(const QString &fileName, bool inProject, bool onlyIfNotParsed, bool updateView, std::weak_ptr<CppParser> parserPtr)
|
||||||
{
|
{
|
||||||
if (!mEnabled)
|
if (!mEnabled)
|
||||||
return;
|
return;
|
||||||
|
@ -1001,6 +1001,7 @@ void CppParser::parseFile(const QString &fileName, bool inProject, bool onlyIfNo
|
||||||
mLastParseFileCommand->inProject = inProject;
|
mLastParseFileCommand->inProject = inProject;
|
||||||
mLastParseFileCommand->onlyIfNotParsed = onlyIfNotParsed;
|
mLastParseFileCommand->onlyIfNotParsed = onlyIfNotParsed;
|
||||||
mLastParseFileCommand->updateView = updateView;
|
mLastParseFileCommand->updateView = updateView;
|
||||||
|
mLastParseFileCommand->parserPtr = parserPtr;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mLockCount>0)
|
if (mLockCount>0)
|
||||||
|
@ -1020,8 +1021,9 @@ void CppParser::parseFile(const QString &fileName, bool inProject, bool onlyIfNo
|
||||||
emit onEndParsing(mFilesScannedCount,0);
|
emit onEndParsing(mFilesScannedCount,0);
|
||||||
|
|
||||||
if (mLastParseFileCommand) {
|
if (mLastParseFileCommand) {
|
||||||
mParsing = false;
|
PCppParser parser=mLastParseFileCommand->parserPtr.lock();
|
||||||
::parseFile(PCppParser{this},
|
if (parser)
|
||||||
|
::parseFile(parser,
|
||||||
mLastParseFileCommand->fileName,
|
mLastParseFileCommand->fileName,
|
||||||
mLastParseFileCommand->inProject,
|
mLastParseFileCommand->inProject,
|
||||||
mLastParseFileCommand->onlyIfNotParsed,
|
mLastParseFileCommand->onlyIfNotParsed,
|
||||||
|
@ -6768,7 +6770,7 @@ CppFileParserThread::CppFileParserThread(
|
||||||
void CppFileParserThread::run()
|
void CppFileParserThread::run()
|
||||||
{
|
{
|
||||||
if (mParser) {
|
if (mParser) {
|
||||||
mParser->parseFile(mFileName,mInProject,mOnlyIfNotParsed,mUpdateView);
|
mParser->parseFile(mFileName,mInProject,mOnlyIfNotParsed,mUpdateView,mParser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@ public:
|
||||||
bool inProject;
|
bool inProject;
|
||||||
bool onlyIfNotParsed;
|
bool onlyIfNotParsed;
|
||||||
bool updateView;
|
bool updateView;
|
||||||
|
std::weak_ptr<CppParser> parserPtr;
|
||||||
};
|
};
|
||||||
|
|
||||||
using PParseFileCommand = std::unique_ptr<ParseFileCommand>;
|
using PParseFileCommand = std::unique_ptr<ParseFileCommand>;
|
||||||
|
@ -119,7 +120,8 @@ public:
|
||||||
bool isProjectHeaderFile(const QString& fileName);
|
bool isProjectHeaderFile(const QString& fileName);
|
||||||
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 = nullptr);
|
||||||
void parseFileList(bool updateView = true);
|
void parseFileList(bool updateView = true);
|
||||||
void parseHardDefines();
|
void parseHardDefines();
|
||||||
bool parsing() const;
|
bool parsing() const;
|
||||||
|
|
Loading…
Reference in New Issue