From 6fa4dd0a977634f5693c759ea87ae8411399c629 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Mon, 30 Oct 2017 12:26:02 +0100 Subject: [PATCH] Fix qml binding loops --- resources/qml/MonitorButton.qml | 6 +++++- resources/qml/SaveButton.qml | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/resources/qml/MonitorButton.qml b/resources/qml/MonitorButton.qml index 7a620c42ea..67ca2e708e 100644 --- a/resources/qml/MonitorButton.qml +++ b/resources/qml/MonitorButton.qml @@ -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 diff --git a/resources/qml/SaveButton.qml b/resources/qml/SaveButton.qml index 63c44a6720..e2890a6b49 100644 --- a/resources/qml/SaveButton.qml +++ b/resources/qml/SaveButton.qml @@ -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 }