- fix: Crash when scroll file which has more than 65535 lines.

- fix: Can't scroll to lines greater than 65535.
This commit is contained in:
Roy Qu 2022-12-14 09:20:53 +08:00
parent 4093f29ac4
commit 13f0be3154
3 changed files with 10 additions and 26 deletions

View File

@ -19,7 +19,8 @@ Red Panda C++ Version 2.6
- enhancement: Auto disable "compile" button if gcc doesn't exist.
- enhancement: Auto disable "debug" button if gdb doesn't exist.
- enhancement: Auto disable "compile" button for project if make doesn't exist.
- Fix: Crash when scroll file which has more than 65535 lines.
- fix: Crash when scroll file which has more than 65535 lines.
- fix: Can't scroll to lines greater than 65535.
Red Panda C++ Version 2.5

View File

@ -27,9 +27,6 @@ extern const QChar TabGlyph;
extern const QChar LineBreakGlyph;
extern const QChar SoftBreakGlyph;
#define MAX_SCROLL 65535
// names for token attributes
#define SYNS_AttrAssembler "Assembler"
#define SYNS_AttrCharacter "Character"

View File

@ -3238,17 +3238,10 @@ void SynEdit::updateScrollbars()
}
if (mScrollBars == ScrollStyle::ssBoth || mScrollBars == ScrollStyle::ssHorizontal) {
nMaxScroll = maxScrollWidth();
if (nMaxScroll <= MAX_SCROLL) {
nMin = 1;
nMax = nMaxScroll;
nPage = mCharsInWindow;
nPos = mLeftChar;
} else {
nMin = 1;
nMax = MAX_SCROLL;
nPage = mulDiv(MAX_SCROLL, mCharsInWindow, nMaxScroll);
nPos = mulDiv(MAX_SCROLL, mLeftChar, nMaxScroll);
}
nMin = 1;
nMax = nMaxScroll;
nPage = mCharsInWindow;
nPos = mLeftChar;
horizontalScrollBar()->setMinimum(nMin);
horizontalScrollBar()->setMaximum(nMax);
horizontalScrollBar()->setPageStep(nPage);
@ -3259,17 +3252,10 @@ void SynEdit::updateScrollbars()
if (mScrollBars == ScrollStyle::ssBoth || mScrollBars == ScrollStyle::ssVertical) {
nMaxScroll = maxScrollHeight();
if (nMaxScroll <= MAX_SCROLL) {
nMin = 1;
nMax = std::max(1, nMaxScroll);
nPage = mLinesInWindow;
nPos = mTopLine;
} else {
nMin = 1;
nMax = MAX_SCROLL;
nPage = mulDiv(MAX_SCROLL, mLinesInWindow, nMaxScroll);
nPos = mulDiv(MAX_SCROLL, mTopLine, nMaxScroll);
}
nMin = 1;
nMax = std::max(1, nMaxScroll);
nPage = mLinesInWindow;
nPos = mTopLine;
verticalScrollBar()->setMinimum(nMin);
verticalScrollBar()->setMaximum(nMax);
verticalScrollBar()->setPageStep(nPage);