From 40993321cd67c1fe722977ed94c91cedff4bb1f8 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Wed, 7 Oct 2020 23:44:44 +0200 Subject: QQuickTextEdit: ensure we update document width when padding has changed We use an if-test to check if the document width has changed before we set the new value. The problem is that the value we test against is different than the value we set. The result is that we can sometimes skip setting a new width on the document, even if padding has changed. This patch ensures that we use the same width for both testing and setting. Pick-to: 5.15 Change-Id: Ia8391999e8cc2b5be72fe525d396bf8c17ba0fa2 Reviewed-by: Mitch Curtis --- src/quick/items/qquicktextedit.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp index aa07758a5d..566c9c3f6f 100644 --- a/src/quick/items/qquicktextedit.cpp +++ b/src/quick/items/qquicktextedit.cpp @@ -2530,8 +2530,9 @@ void QQuickTextEdit::updateSize() if (d->inLayout) // probably the result of a binding loop, but by letting it return; // get this far we'll get a warning to that effect. } - if (d->document->textWidth() != width()) { - d->document->setTextWidth(width() - leftPadding() - rightPadding()); + const qreal newTextWidth = width() - leftPadding() - rightPadding(); + if (d->document->textWidth() != newTextWidth) { + d->document->setTextWidth(newTextWidth); newWidth = d->document->idealWidth(); } //### need to confirm cost of always setting these -- cgit v1.2.3