From 800d3828c1b3e0dfd5c365d9f4cbc86eee894bab Mon Sep 17 00:00:00 2001 From: Cyano Hao Date: Thu, 12 Sep 2024 13:41:15 +0800 Subject: [PATCH] fix namespace crash (royqh1979#471) (#483) --- RedPandaIDE/parser/cppparser.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index 8ad50205..0c2d49a2 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -6071,8 +6071,7 @@ void CppParser::internalInvalidateFile(const QString &fileName) } //remove all statements from namespace cache - for (auto it=mNamespaces.begin();it!=mNamespaces.end();++it) { - QString key = it.key(); + for (auto it=mNamespaces.begin();it!=mNamespaces.end();) { PStatementList statements = it.value(); for (int i=statements->size()-1;i>=0;i--) { PStatement statement = statements->at(i); @@ -6081,7 +6080,9 @@ void CppParser::internalInvalidateFile(const QString &fileName) } } if (statements->isEmpty()) { - mNamespaces.remove(key); + it = mNamespaces.erase(it); + } else { + ++it; } } // class inheritance