diff options
author | mae <qt-info@nokia.com> | 2009-12-14 17:13:23 +0100 |
---|---|---|
committer | mae <qt-info@nokia.com> | 2009-12-14 17:14:52 +0100 |
commit | 2ba459c2adcaa4d0f865956048ac2e24f3fe6924 (patch) | |
tree | f2394e59af3057803045cb772208bc4e77aaf087 /src/gui/widgets/qplaintextedit.cpp | |
parent | dff377e72c1c84aefd81cf92da75d65562bec6b6 (diff) |
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.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp index 89fe7b80a1..028ffe8501 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); |