summaryrefslogtreecommitdiffstats
path: root/src/gui/widgets/qplaintextedit.cpp
diff options
context:
space:
mode:
authormae <qt-info@nokia.com>2009-12-14 16:13:23 (GMT)
committermae <qt-info@nokia.com>2009-12-14 16:14:52 (GMT)
commit2ba459c2adcaa4d0f865956048ac2e24f3fe6924 (patch)
treef2394e59af3057803045cb772208bc4e77aaf087 /src/gui/widgets/qplaintextedit.cpp
parentdff377e72c1c84aefd81cf92da75d65562bec6b6 (diff)
downloadQt-2ba459c2adcaa4d0f865956048ac2e24f3fe6924.zip
Qt-2ba459c2adcaa4d0f865956048ac2e24f3fe6924.tar.gz
Qt-2ba459c2adcaa4d0f865956048ac2e24f3fe6924.tar.bz2
QPlainTextEdit scrolling issue with folded paragraphs
With Qt Creator, we could reproduce scrolling problems when paragraphs were folded away. Effectively the first "visible" block could be an invisible one, resulting in firstVisibleBlock() returning something bogus. The result were drawing errors. Reviewed-by: con
Diffstat (limited to 'src/gui/widgets/qplaintextedit.cpp')
-rw-r--r--src/gui/widgets/qplaintextedit.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp
index 89fe7b8..028ffe8 100644
--- a/src/gui/widgets/qplaintextedit.cpp
+++ b/src/gui/widgets/qplaintextedit.cpp
@@ -684,8 +684,12 @@ void QPlainTextEditPrivate::ensureVisible(int position, bool center, bool forceC
qreal h = center ? line.naturalTextRect().center().y() : line.naturalTextRect().bottom();
+ QTextBlock previousVisibleBlock = block;
while (h < height && block.previous().isValid()) {
- block = block.previous();
+ previousVisibleBlock = block;
+ do {
+ block = block.previous();
+ } while (!block.isVisible() && block.previous().isValid());
h += q->blockBoundingRect(block).height();
}
@@ -699,8 +703,8 @@ void QPlainTextEditPrivate::ensureVisible(int position, bool center, bool forceC
++l;
}
- if (block.next().isValid() && l >= lineCount) {
- block = block.next();
+ if (l >= lineCount) {
+ block = previousVisibleBlock;
l = 0;
}
setTopBlock(block.blockNumber(), l);