diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2018-06-06 11:35:26 +0200 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2018-06-06 12:04:53 +0000 |
commit | 500fbe43712f9a961efbca35c9f5b9cfdf0173a5 (patch) | |
tree | a6545a51ce6b6f56d101ba285347066e4ca63d2c /src/quicktemplates2 | |
parent | 9a5f28de79eaeefcb91134cc124b7990c5c72fef (diff) |
QQuickControl: only set hasBackgroundWidth/Height when necessary
The following binding in the Fusion style's TabButton.qml
implementation causes the last tab's background not to cover its full
width:
height: control.height - (control.checked ? 0 : 2)
It seems that this line is executed upon the completion of
deferred execution of the background, which somehow results in the
early return check in itemGeometryChanged() not being executed.
After that, there are these two lines:
extra.value().hasBackgroundWidth = p->widthValid;
extra.value().hasBackgroundHeight = p->heightValid;
Even though this was just a change in height, hasBackgroundWidth was
set to true early on (when the width was 8; the combined left and right
padding), preventing the control from setting a width on the background
in the future.
This patch fixes the issue by only setting hasBackgroundWidth if the
width was changed, and only setting hasBackgroundHeight if the height
was changed.
Task-number: QTBUG-68556
Change-Id: I4c7dbc60d8e73c60c025e5d6c65f3917e6e4ea08
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/quicktemplates2')
-rw-r--r-- | src/quicktemplates2/qquickcontrol.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp index 14887a07..38f3212a 100644 --- a/src/quicktemplates2/qquickcontrol.cpp +++ b/src/quicktemplates2/qquickcontrol.cpp @@ -883,8 +883,12 @@ void QQuickControlPrivate::itemGeometryChanged(QQuickItem *item, QQuickGeometryC return; QQuickItemPrivate *p = QQuickItemPrivate::get(item); - extra.value().hasBackgroundWidth = p->widthValid; - extra.value().hasBackgroundHeight = p->heightValid; + // Only set hasBackgroundWidth/Height if it was a width/height change, + // otherwise we're prevented from setting a width/height in the future. + if (change.widthChange()) + extra.value().hasBackgroundWidth = p->widthValid; + if (change.heightChange()) + extra.value().hasBackgroundHeight = p->heightValid; resizeBackground(); } |