aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquicktextedit.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-11-05 15:38:10 +0100
committerLars Knoll <lars.knoll@qt.io>2018-11-22 08:25:43 +0000
commit560a1991ac4524ff16352da23a2b54d717548f33 (patch)
tree565b58ab1b724a772e1dce2d4f421832cbfca5f8 /src/quick/items/qquicktextedit.cpp
parent6b3365b2ea3b445cae2cf657392176bff19a0fe4 (diff)
Fix updating of text nodes in QQuickTextEdit
The update algorithm wasn't working correctly if there were two disconnected dirty regions in the textNodeMap. This could happend by e.g. programatically removing text at the beginning and appending at the end. Change-Id: I3de2c8efedb03c004c4c304d130360cbdb4485b7 Fixes: QTBUG-68863 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src/quick/items/qquicktextedit.cpp')
-rw-r--r--src/quick/items/qquicktextedit.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp
index bfc9f4c769..328f7c9103 100644
--- a/src/quick/items/qquicktextedit.cpp
+++ b/src/quick/items/qquicktextedit.cpp
@@ -2044,11 +2044,22 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *
int firstDirtyPos = 0;
if (nodeIterator != d->textNodeMap.end()) {
firstDirtyPos = nodeIterator->startPos();
+ // ### this could be optimized if the first and last dirty nodes are not connected
+ // as the intermediate text nodes would usually only need to be transformed differently.
+ int lastDirtyPos = firstDirtyPos;
+ auto it = d->textNodeMap.constEnd();
+ while (it != nodeIterator) {
+ --it;
+ if (it->dirty()) {
+ lastDirtyPos = it->startPos();
+ break;
+ }
+ }
do {
rootNode->removeChildNode(nodeIterator->textNode());
delete nodeIterator->textNode();
nodeIterator = d->textNodeMap.erase(nodeIterator);
- } while (nodeIterator != d->textNodeMap.end() && nodeIterator->dirty());
+ } while (nodeIterator != d->textNodeMap.constEnd() && nodeIterator->startPos() <= lastDirtyPos);
}
// FIXME: the text decorations could probably be handled separately (only updated for affected textFrames)