diff options
author | Axel Spoerl <axel.spoerl@qt.io> | 2023-02-17 12:42:50 +0100 |
---|---|---|
committer | Axel Spoerl <axel.spoerl@qt.io> | 2023-03-15 23:45:00 +0100 |
commit | 09c3cd8503102c70c7d5bf41c0b662b2c86b4ad0 (patch) | |
tree | 4936d13bbbc05c32fbbbdd6d33992a29e1abcf91 /src/widgets/widgets | |
parent | 99975ec07feb6b1a9f6be9e0d392a35e40f9550a (diff) |
QPlainTextEdit: Don't block signals on page step
Signals of the vertical scroll bar were blocked when scrolling with
pageUp/pageDown keys or clicking on the scroll range outside the
scroll bar. This has lead to inconsistent signal emissions:
The vertical scroll bar's valueChanged signal was emitted only on
single steps and when the scroll bar was moved with the mouse.
When it was moved in page steps by clicking on the scroll range or
pressing pageUp/pageDown, it was not emitted.
This patch removes the signal blocker for page step movements, which
was added in 94fd108ea42a99dacefa819bc3fd4363fb95e886 to replace
explicit calls to blockSignals(), which were added in
c14d442b08ac81327b173b0a220c7b1840667899.
The patch also adds test function to tst_QPlainTextEdit to check if
the valueChanged signal is emitted correctly.
Pick-to: 6.5 6.4 6.2
Fixes: QTBUG-8682
Fixes: QTBUG-25365
Change-Id: I4385a5387c91497f623978e35bbbe3e06f473afe
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r-- | src/widgets/widgets/qplaintextedit.cpp | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp index f3cc34c088..9ca2a84d07 100644 --- a/src/widgets/widgets/qplaintextedit.cpp +++ b/src/widgets/widgets/qplaintextedit.cpp @@ -629,10 +629,7 @@ void QPlainTextEditPrivate::setTopBlock(int blockNumber, int lineNumber, int dx) lineNumber = maxTopLine - block.firstLineNumber(); } - { - const QSignalBlocker blocker(vbar); - vbar->setValue(newTopLine); - } + vbar->setValue(newTopLine); if (!dx && blockNumber == control->topBlock && lineNumber == topLine) return; @@ -648,10 +645,7 @@ void QPlainTextEditPrivate::setTopBlock(int blockNumber, int lineNumber, int dx) control->topBlock = blockNumber; topLine = lineNumber; - { - const QSignalBlocker blocker(vbar); - vbar->setValue(block.firstLineNumber() + lineNumber); - } + vbar->setValue(block.firstLineNumber() + lineNumber); if (dx || dy) { viewport->scroll(q->isRightToLeft() ? -dx : dx, dy); @@ -1012,10 +1006,7 @@ void QPlainTextEditPrivate::_q_adjustScrollbars() if (firstVisibleBlock.isValid()) visualTopLine = firstVisibleBlock.firstLineNumber() + topLine; - { - const QSignalBlocker blocker(vbar); - vbar->setValue(visualTopLine); - } + vbar->setValue(visualTopLine); hbar->setRange(0, (int)documentSize.width() - viewport->width()); hbar->setPageStep(viewport->width()); |