- fix: index out of range in cpp highlighter

- fix: memory leak in code folding processing
This commit is contained in:
Roy Qu 2022-10-19 22:54:08 +08:00
parent fc8e37d55e
commit 98f4766ffd
4 changed files with 18 additions and 21 deletions

View File

@ -29,6 +29,8 @@ Red Panda C++ Version 1.5
- fix: ctrl+click on #include_next header name doesn't open the right file
- enhancement: parser used for non-project C files won't search header files in C++ include folders.
- fix: toggle block comment/delete to word begin/delete to word end are not correctly disabled when editor not open
- fix: index out of range in cpp highlighter
- fix: memory leak in code folding processing
Red Panda C++ Version 1.4

View File

@ -72,16 +72,15 @@ void CodeFoldingRange::move(int count)
toLine += count;
}
CodeFoldingRange::CodeFoldingRange(PCodeFoldingRange aParent,
int aFromLine,
PCodeFoldingDefine aFoldRegion, int aToLine):
fromLine(aFromLine),
toLine(aToLine),
CodeFoldingRange::CodeFoldingRange(PCodeFoldingRange parent,
int fromLine,
int toLine):
fromLine(fromLine),
toLine(toLine),
linesCollapsed(0),
collapsed(false),
foldRegion(aFoldRegion),
hintMarkLeft(0),
parent(aParent)
parent(parent)
{
subFoldRanges = std::make_shared<CodeFoldingRanges>();
}
@ -107,16 +106,15 @@ CodeFoldingRanges::CodeFoldingRanges()
}
PCodeFoldingRange CodeFoldingRanges::addByParts(PCodeFoldingRange aParent,
PCodeFoldingRanges aAllFold,
int aFromLine,
PCodeFoldingDefine aFoldRegion,
int aToLine)
PCodeFoldingRange CodeFoldingRanges::addByParts(PCodeFoldingRange parent,
PCodeFoldingRanges allFold,
int fromLine,
int toLine)
{
PCodeFoldingRange range=std::make_shared<CodeFoldingRange>(aParent, aFromLine,aFoldRegion,aToLine);
PCodeFoldingRange range=std::make_shared<CodeFoldingRange>(parent, fromLine,toLine);
mRanges.append(range);
if (aAllFold && aAllFold.get()!=this) {
aAllFold->add(range);
if (allFold && allFold.get()!=this) {
allFold->add(range);
}
return range;
}

View File

@ -67,8 +67,8 @@ public:
void clear();
int count() const;
CodeFoldingRanges();
PCodeFoldingRange addByParts(PCodeFoldingRange aParent, PCodeFoldingRanges aAllFold,
int aFromLine, PCodeFoldingDefine aFoldRegion, int aToLine);
PCodeFoldingRange addByParts(PCodeFoldingRange parent, PCodeFoldingRanges allFold,
int fromLine, int toLine);
void insert(int index, PCodeFoldingRange range);
void remove(int index);
@ -84,12 +84,11 @@ public:
int linesCollapsed; // Number of collapsed lines
PCodeFoldingRanges subFoldRanges; // Sub fold ranges
bool collapsed; // Is collapsed?
std::weak_ptr<CodeFoldingDefine> foldRegion; // FoldRegion
int hintMarkLeft;
std::weak_ptr<CodeFoldingRange> parent;
bool parentCollapsed();
void move(int count);
explicit CodeFoldingRange(PCodeFoldingRange aParent, int aFromLine, PCodeFoldingDefine aFoldRegion, int aToLine);
explicit CodeFoldingRange(PCodeFoldingRange parent, int fromLine, int toLine);
};
}

View File

@ -3705,7 +3705,6 @@ void SynEdit::findSubFoldRange(PCodeFoldingRanges TopFoldRanges, int FoldIndex,P
Parent,
TopFoldRanges,
Line + 1,
mCodeFolding.foldRegions.get(FoldIndex),
Line + 1);
parentFoldRanges = Parent->subFoldRanges;
}
@ -3734,7 +3733,6 @@ void SynEdit::findSubFoldRange(PCodeFoldingRanges TopFoldRanges, int FoldIndex,P
Parent,
TopFoldRanges,
Line + 1,
mCodeFolding.foldRegions.get(FoldIndex),
Line + 1);
parentFoldRanges = Parent->subFoldRanges;