From 13f0be31548b2acc2b1c8d9c1ec16731cc1d81fa Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Wed, 14 Dec 2022 09:20:53 +0800 Subject: [PATCH] - fix: Crash when scroll file which has more than 65535 lines. - fix: Can't scroll to lines greater than 65535. --- NEWS.md | 3 ++- libs/qsynedit/qsynedit/Constants.h | 3 --- libs/qsynedit/qsynedit/SynEdit.cpp | 30 ++++++++---------------------- 3 files changed, 10 insertions(+), 26 deletions(-) diff --git a/NEWS.md b/NEWS.md index 1d4026a0..aa2ac379 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 diff --git a/libs/qsynedit/qsynedit/Constants.h b/libs/qsynedit/qsynedit/Constants.h index aa26d42e..c9bbf4f9 100644 --- a/libs/qsynedit/qsynedit/Constants.h +++ b/libs/qsynedit/qsynedit/Constants.h @@ -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" diff --git a/libs/qsynedit/qsynedit/SynEdit.cpp b/libs/qsynedit/qsynedit/SynEdit.cpp index 343e0aec..9ff7b091 100644 --- a/libs/qsynedit/qsynedit/SynEdit.cpp +++ b/libs/qsynedit/qsynedit/SynEdit.cpp @@ -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);