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 --- .../auto/qquickmaterialstyle/data/tst_material.qml | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/qquickmaterialstyle/data/tst_material.qml b/tests/auto/qquickmaterialstyle/data/tst_material.qml index 9f2456b8..45bc0dab 100644 --- a/tests/auto/qquickmaterialstyle/data/tst_material.qml +++ b/tests/auto/qquickmaterialstyle/data/tst_material.qml @@ -715,4 +715,39 @@ TestCase { control.destroy() } + + Component { + id: testResizeBackground + Item { + width: 200 + height: 200 + property alias textArea: textArea + ScrollView { + anchors.fill: parent + ScrollBar.horizontal.policy: ScrollBar.AlwaysOff + TextArea { + id: textArea + wrapMode : TextEdit.WordWrap + readOnly: false + selectByMouse: true + focus: true + text: "test message" + } + } + } + } + + function test_resize_background() { + var control = testCase.createTemporaryObject(testResizeBackground, testCase) + compare(control.textArea.background.height, 1) + compare(control.textArea.background.width, control.width) + control.width = 400 + control.height = 400 + compare(control.textArea.background.height, 1) + compare(control.textArea.background.width, control.width) + control.width = 200 + control.height = 200 + compare(control.textArea.background.height, 1) + compare(control.textArea.background.width, control.width) + } } -- cgit v1.2.3