fix: crash when there are catch block in the upper most scope
This commit is contained in:
parent
6cbab4a646
commit
d81740257a
|
@ -1248,12 +1248,12 @@ bool CppParser::isCurrentScope(const QString &command)
|
||||||
return (statement->command == s);
|
return (statement->command == s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppParser::addSoloScopeLevel(PStatement& statement, int line)
|
void CppParser::addSoloScopeLevel(PStatement& statement, int line, bool shouldResetBlock)
|
||||||
{
|
{
|
||||||
// Add class list
|
// Add class list
|
||||||
|
|
||||||
PStatement parentScope;
|
PStatement parentScope;
|
||||||
if (statement && (statement->kind == StatementKind::skBlock)) {
|
if (shouldResetBlock && statement && (statement->kind == StatementKind::skBlock)) {
|
||||||
parentScope = statement->parentScope.lock();
|
parentScope = statement->parentScope.lock();
|
||||||
while (parentScope && (parentScope->kind == StatementKind::skBlock)) {
|
while (parentScope && (parentScope->kind == StatementKind::skBlock)) {
|
||||||
parentScope = parentScope->parentScope.lock();
|
parentScope = parentScope->parentScope.lock();
|
||||||
|
@ -1852,7 +1852,7 @@ void CppParser::handleCatchBlock()
|
||||||
mClassScope,
|
mClassScope,
|
||||||
true,
|
true,
|
||||||
false);
|
false);
|
||||||
addSoloScopeLevel(block,startLine);
|
addSoloScopeLevel(block,startLine,false);
|
||||||
if (!mTokenizer[mIndex]->text.contains("..."))
|
if (!mTokenizer[mIndex]->text.contains("..."))
|
||||||
scanMethodArgs(block,mTokenizer[mIndex]->text);
|
scanMethodArgs(block,mTokenizer[mIndex]->text);
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,7 +178,7 @@ private:
|
||||||
bool isStatic);
|
bool isStatic);
|
||||||
void setInheritance(int index, const PStatement& classStatement, bool isStruct);
|
void setInheritance(int index, const PStatement& classStatement, bool isStruct);
|
||||||
bool isCurrentScope(const QString& command);
|
bool isCurrentScope(const QString& command);
|
||||||
void addSoloScopeLevel(PStatement& statement, int line); // adds new solo level
|
void addSoloScopeLevel(PStatement& statement, int line, bool shouldResetBlock = true); // adds new solo level
|
||||||
void removeScopeLevel(int line); // removes level
|
void removeScopeLevel(int line); // removes level
|
||||||
int skipBraces(int startAt);
|
int skipBraces(int startAt);
|
||||||
int skipBracket(int startAt);
|
int skipBracket(int startAt);
|
||||||
|
|
Loading…
Reference in New Issue