From da06da57002b64cf4bcde0ca708b3275a5f919ae Mon Sep 17 00:00:00 2001 From: Wang Chuan Date: Wed, 17 Jul 2019 17:41:16 +0800 Subject: QQuickTextArea: prevent changing size of background recursively When the x/y position of background depends on the height/width of background and these values are not constant, the if statement in the method resizeBackground() will always pass. And since a change listener is set before calling setHeight()/setWidth() in background, these two method will always call resizeBackground() and then call themself recursively, that means the height/width of background will always be reset, no matter what value you set. [ChangeLog][QtQuick][QQuickTextArea] defer adding change listener and prevent changing size of background recursively in construction Fixes: QTBUG-76369 Change-Id: I2ec37cad7f35cb1c756276326fe69e860c6b8de5 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquicktextarea.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/quicktemplates2/qquicktextarea.cpp') diff --git a/src/quicktemplates2/qquicktextarea.cpp b/src/quicktemplates2/qquicktextarea.cpp index 95dd9f93..95bf5bb1 100644 --- a/src/quicktemplates2/qquicktextarea.cpp +++ b/src/quicktemplates2/qquicktextarea.cpp @@ -512,8 +512,11 @@ void QQuickTextAreaPrivate::executeBackground(bool complete) if (!background || complete) quickBeginDeferred(q, backgroundName(), background); - if (complete) + if (complete) { quickCompleteDeferred(q, backgroundName(), background); + if (background) + QQuickControlPrivate::addImplicitSizeListener(background, this, QQuickControlPrivate::ImplicitSizeChanges | QQuickItemPrivate::Geometry); + } } void QQuickTextAreaPrivate::itemImplicitWidthChanged(QQuickItem *item) @@ -633,9 +636,10 @@ void QQuickTextArea::setBackground(QQuickItem *background) d->extra.value().hasBackgroundWidth = p->widthValid; d->extra.value().hasBackgroundHeight = p->heightValid; } - if (isComponentComplete()) + if (isComponentComplete()) { d->resizeBackground(); - QQuickControlPrivate::addImplicitSizeListener(background, d, QQuickControlPrivate::ImplicitSizeChanges | QQuickItemPrivate::Geometry); + QQuickControlPrivate::addImplicitSizeListener(background, d, QQuickControlPrivate::ImplicitSizeChanges | QQuickItemPrivate::Geometry); + } } if (!qFuzzyCompare(oldImplicitBackgroundWidth, implicitBackgroundWidth())) -- cgit v1.2.3