From 560a1991ac4524ff16352da23a2b54d717548f33 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 5 Nov 2018 15:38:10 +0100 Subject: 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 --- src/quick/items/qquicktextedit.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/quick/items/qquicktextedit.cpp') 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) -- cgit v1.2.3