From 8837ffc06ddd7a9177e52339088a0f89c2a28624 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Tue, 25 Sep 2018 11:52:50 +0200 Subject: [PATCH] Fix mateial management QML reference CURA-5682 --- .../Preferences/Materials/MaterialsDetailsPanel.qml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/resources/qml/Preferences/Materials/MaterialsDetailsPanel.qml b/resources/qml/Preferences/Materials/MaterialsDetailsPanel.qml index f72d93aff3..92970f40e2 100644 --- a/resources/qml/Preferences/Materials/MaterialsDetailsPanel.qml +++ b/resources/qml/Preferences/Materials/MaterialsDetailsPanel.qml @@ -27,9 +27,20 @@ Item function updateMaterialPropertiesObject() { + // DRAGON WARNING!!! DO NOT TOUCH THIS IF YOU DON'T KNOW. + // TL;DR: Always update "container_id" first! + // + // Other widgets such as MaterialsView have bindings towards "materialProperties" and its properties. Here the + // properties are updated one by one, and each change can trigger a reaction on those widgets that have + // connections to the property gets changed, and some reactions will use functions such as + // ContainerManager.getContainerMetaDataEntry() to fetch data using the "container_id" as the reference. + // We need to change "container_id" first so any underlying triggers will use the correct "container_id" to + // fetch data. Or, for example, if we change GUID first, which triggered the weight widget to fetch weight + // before we can update "container_id", so it will fetch weight with the wrong (old) "container_id". + materialProperties.container_id = currentItem.id + materialProperties.name = currentItem.name || "Unknown" materialProperties.guid = currentItem.GUID - materialProperties.container_id = currentItem.id materialProperties.brand = currentItem.brand || "Unknown" materialProperties.material = currentItem.material || "Unknown" materialProperties.color_name = currentItem.color_name || "Yellow"