Controls: Bypass bindings when setting x and y in resizeBackground
Using setX() and setY() instead can remove the binding for them. Fixes: QTBUG-120033 Change-Id: I77fc5360b2d10436b5e258b5f0ceb96b949eccbe Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commitbb7ba7667b
) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commitac17f948cd
) (cherry picked from commit118f9999fe
) Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit3f9cfda169
)
This commit is contained in:
parent
486a0b2ebf
commit
38dac54f6a
|
@ -385,12 +385,22 @@ void QQuickControlPrivate::resizeBackground()
|
|||
bool changeHeight = false;
|
||||
if (((!p->widthValid() || !extra.isAllocated() || !extra->hasBackgroundWidth) && qFuzzyIsNull(background->x()))
|
||||
|| (extra.isAllocated() && (extra->hasLeftInset || extra->hasRightInset))) {
|
||||
background->setX(getLeftInset());
|
||||
const auto leftInset = getLeftInset();
|
||||
if (!qt_is_nan(leftInset) && p->x.valueBypassingBindings() != leftInset) {
|
||||
// We bypass the binding here to prevent it from being removed
|
||||
p->x.setValueBypassingBindings(leftInset);
|
||||
p->dirty(DirtyType::Position);
|
||||
}
|
||||
changeWidth = !p->width.hasBinding();
|
||||
}
|
||||
if (((!p->heightValid() || !extra.isAllocated() || !extra->hasBackgroundHeight) && qFuzzyIsNull(background->y()))
|
||||
|| (extra.isAllocated() && (extra->hasTopInset || extra->hasBottomInset))) {
|
||||
background->setY(getTopInset());
|
||||
const auto topInset = getTopInset();
|
||||
if (!qt_is_nan(topInset) && p->y.valueBypassingBindings() != topInset) {
|
||||
// We bypass the binding here to prevent it from being removed
|
||||
p->y.setValueBypassingBindings(topInset);
|
||||
p->dirty(DirtyType::Position);
|
||||
}
|
||||
changeHeight = !p->height.hasBinding();
|
||||
}
|
||||
if (changeHeight || changeWidth) {
|
||||
|
|
|
@ -502,6 +502,36 @@ TestCase {
|
|||
verify(control.background.height !== control.height)
|
||||
}
|
||||
|
||||
Component {
|
||||
id: backgroundTest2
|
||||
Button {
|
||||
id: btn
|
||||
width: 100
|
||||
height: 100
|
||||
topInset: 0
|
||||
objectName: ""
|
||||
|
||||
background: Rectangle {
|
||||
id: bg
|
||||
implicitHeight: 80
|
||||
border.color: "red"
|
||||
y: btn.objectName === "aaa" ? 20 : 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// QTBUG-120033: Make sure that the binding for y on the tab button's background doesn't get removed
|
||||
function test_background2() {
|
||||
let button = createTemporaryObject(backgroundTest2, testCase)
|
||||
verify(button)
|
||||
|
||||
verify(button.background.y === 0)
|
||||
button.objectName = "aaa"
|
||||
verify(button.background.y === 20)
|
||||
button.objectName = ""
|
||||
verify(button.background.y === 0)
|
||||
}
|
||||
|
||||
Component {
|
||||
id: component2
|
||||
T.Control {
|
||||
|
|
Loading…
Reference in New Issue