fix namespace crash (royqh1979#471) (#483)

This commit is contained in:
Cyano Hao 2024-09-12 13:41:15 +08:00 committed by GitHub
parent 0b39a71d02
commit 800d3828c1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 3 deletions

View File

@ -6071,8 +6071,7 @@ void CppParser::internalInvalidateFile(const QString &fileName)
} }
//remove all statements from namespace cache //remove all statements from namespace cache
for (auto it=mNamespaces.begin();it!=mNamespaces.end();++it) { for (auto it=mNamespaces.begin();it!=mNamespaces.end();) {
QString key = it.key();
PStatementList statements = it.value(); PStatementList statements = it.value();
for (int i=statements->size()-1;i>=0;i--) { for (int i=statements->size()-1;i>=0;i--) {
PStatement statement = statements->at(i); PStatement statement = statements->at(i);
@ -6081,7 +6080,9 @@ void CppParser::internalInvalidateFile(const QString &fileName)
} }
} }
if (statements->isEmpty()) { if (statements->isEmpty()) {
mNamespaces.remove(key); it = mNamespaces.erase(it);
} else {
++it;
} }
} }
// class inheritance // class inheritance