Fix qml binding loops

This commit is contained in:
fieldOfView 2017-10-30 12:26:02 +01:00
parent 84002a70d0
commit 6fa4dd0a97
2 changed files with 19 additions and 3 deletions

View File

@ -188,7 +188,11 @@ Item
Item {
id: buttonsRow
height: abortButton.height
width: Math.min(childrenRect.width, base.width - 2 * UM.Theme.getSize("sidebar_margin").width)
width: {
// using childrenRect.width directly causes a binding loop, because setting the width affects the childrenRect
var children_width = additionalComponentsRow.width + pauseResumeButton.width + abortButton.width + 3 * UM.Theme.getSize("default_margin").width;
return Math.min(children_width, base.width - 2 * UM.Theme.getSize("sidebar_margin").width);
}
anchors.top: progressBar.bottom
anchors.topMargin: UM.Theme.getSize("sidebar_margin").height
anchors.right: parent.right

View File

@ -91,7 +91,19 @@ Item {
Item {
id: saveRow
width: Math.min(childrenRect.width + UM.Theme.getSize("sidebar_margin").width, base.width - UM.Theme.getSize("sidebar_margin").width)
width: {
// using childrenRect.width directly causes a binding loop, because setting the width affects the childrenRect
var children_width = UM.Theme.getSize("default_margin").width;
for (var index in children)
{
var child = children[index];
if(child.visible)
{
children_width += child.width + child.anchors.rightMargin;
}
}
return Math.min(children_width, base.width - UM.Theme.getSize("sidebar_margin").width);
}
height: saveToButton.height
anchors.bottom: parent.bottom
anchors.bottomMargin: UM.Theme.getSize("sidebar_margin").height
@ -102,7 +114,7 @@ Item {
id: additionalComponentsRow
anchors.top: parent.top
anchors.right: saveToButton.visible ? saveToButton.left : parent.right
anchors.rightMargin: UM.Theme.getSize("sidebar_margin").width
anchors.rightMargin: UM.Theme.getSize("default_margin").width
spacing: UM.Theme.getSize("default_margin").width
}