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>
This commit is contained in:
Lars Knoll 2018-11-05 15:38:10 +01:00
parent 6b3365b2ea
commit 560a1991ac
1 changed files with 12 additions and 1 deletions

View File

@ -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)