From d81740257ad0f96556db93227cb95e5d58b1122e Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Wed, 9 Feb 2022 20:50:01 +0800 Subject: [PATCH 1/2] fix: crash when there are catch block in the upper most scope --- RedPandaIDE/parser/cppparser.cpp | 6 +++--- RedPandaIDE/parser/cppparser.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index 3199cf12..6bfcc71f 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -1248,12 +1248,12 @@ bool CppParser::isCurrentScope(const QString &command) return (statement->command == s); } -void CppParser::addSoloScopeLevel(PStatement& statement, int line) +void CppParser::addSoloScopeLevel(PStatement& statement, int line, bool shouldResetBlock) { // Add class list PStatement parentScope; - if (statement && (statement->kind == StatementKind::skBlock)) { + if (shouldResetBlock && statement && (statement->kind == StatementKind::skBlock)) { parentScope = statement->parentScope.lock(); while (parentScope && (parentScope->kind == StatementKind::skBlock)) { parentScope = parentScope->parentScope.lock(); @@ -1852,7 +1852,7 @@ void CppParser::handleCatchBlock() mClassScope, true, false); - addSoloScopeLevel(block,startLine); + addSoloScopeLevel(block,startLine,false); if (!mTokenizer[mIndex]->text.contains("...")) scanMethodArgs(block,mTokenizer[mIndex]->text); } diff --git a/RedPandaIDE/parser/cppparser.h b/RedPandaIDE/parser/cppparser.h index e4e888ca..05d140f9 100644 --- a/RedPandaIDE/parser/cppparser.h +++ b/RedPandaIDE/parser/cppparser.h @@ -178,7 +178,7 @@ private: bool isStatic); void setInheritance(int index, const PStatement& classStatement, bool isStruct); 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 int skipBraces(int startAt); int skipBracket(int startAt); From ad0417aec87c391da6490acf44f21cadfc0e56f1 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Wed, 9 Feb 2022 20:52:15 +0800 Subject: [PATCH 2/2] update NEWS.md --- NEWS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS.md b/NEWS.md index dbcbc22a..f25e1c35 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,7 @@ Red Panda C++ Version 0.14.2 - enhancement: file system view mode for project - enhancement: remove / rename / create new folder in the files view + - fix: crash when there are catch blocks in the upper most scope Red Panda C++ Version 0.14.1 - enhancement: custom theme