From 443252ae10765a0d33facc31a00414df85da78f8 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Wed, 7 Dec 2022 16:57:35 +0100 Subject: [PATCH] =?UTF-8?q?Use=20globalStackExtruderIds=20instead=20of=20e?= =?UTF-8?q?xtruderIds.=20extruderIds=20notifys=20change=20before=20the=20e?= =?UTF-8?q?xtruders=20change=20when=20doing=20a=20machine=20swap.=20Fixing?= =?UTF-8?q?=20this=20will=20take=20a=20long=20time=20so=20this=20is=20a=20?= =?UTF-8?q?workaround.=20If=20you=20are=20reading=20this=20=F0=9F=99=8F=20?= =?UTF-8?q?good=20luck=20fixing=20it=20=F0=9F=99=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CURA-9793 --- cura/Settings/ExtruderManager.py | 7 +++++++ resources/qml/Widgets/SingleSettingComboBox.qml | 2 +- resources/qml/Widgets/SingleSettingSlider.qml | 2 +- resources/qml/Widgets/SingleSettingTextField.qml | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cura/Settings/ExtruderManager.py b/cura/Settings/ExtruderManager.py index dec4a74d27..8d38c7d46e 100755 --- a/cura/Settings/ExtruderManager.py +++ b/cura/Settings/ExtruderManager.py @@ -63,6 +63,13 @@ class ExtruderManager(QObject): # The emit function can't be directly connected to another signal. This wrapper function is required. self.globalStackExtrudersChanged.emit() + @pyqtProperty("QVariantMap", notify = globalStackExtrudersChanged) + def globalStackExtruderIds(self) -> Dict[str, str]: + # The extruderIds property notifys changed before the extruders are changed on switching machines + # trying to fix this broke to many things. This is a workaround. Don't use this unless you need to read + # extruderIds directly after a machine update. + return self.extruderIds + @pyqtProperty(str, notify = activeExtruderChanged) def activeExtruderStackId(self) -> Optional[str]: """Gets the unique identifier of the currently active extruder stack. diff --git a/resources/qml/Widgets/SingleSettingComboBox.qml b/resources/qml/Widgets/SingleSettingComboBox.qml index 9d3f0402c3..95b2c5d86a 100644 --- a/resources/qml/Widgets/SingleSettingComboBox.qml +++ b/resources/qml/Widgets/SingleSettingComboBox.qml @@ -54,7 +54,7 @@ Cura.ComboBox { property UM.SettingPropertyProvider propertyProvider: UM.SettingPropertyProvider { id: propertyProvider - containerStackId: updateAllExtruders ? Cura.ExtruderManager.extruderIds[defaultExtruderIndex] : Cura.MachineManager.activeMachine.id + containerStackId: updateAllExtruders ? Cura.ExtruderManager.globalStackExtruderIds[defaultExtruderIndex] : Cura.MachineManager.activeMachine.id watchedProperties: ["value" , "options"] } diff --git a/resources/qml/Widgets/SingleSettingSlider.qml b/resources/qml/Widgets/SingleSettingSlider.qml index 24692f75fc..2dbb104032 100644 --- a/resources/qml/Widgets/SingleSettingSlider.qml +++ b/resources/qml/Widgets/SingleSettingSlider.qml @@ -34,7 +34,7 @@ RowLayout UM.SettingPropertyProvider { id: propertyProvider - containerStackId: updateAllExtruders ? Cura.ExtruderManager.extruderIds[defaultExtruderIndex] : Cura.MachineManager.activeMachine.id + containerStackId: updateAllExtruders ? Cura.ExtruderManager.globalStackExtruderIds[defaultExtruderIndex] : Cura.MachineManager.activeMachine.id watchedProperties: ["value"] storeIndex: 0 } diff --git a/resources/qml/Widgets/SingleSettingTextField.qml b/resources/qml/Widgets/SingleSettingTextField.qml index 4def7f4179..6d9586caa5 100644 --- a/resources/qml/Widgets/SingleSettingTextField.qml +++ b/resources/qml/Widgets/SingleSettingTextField.qml @@ -53,7 +53,7 @@ UM.TextField { id: propertyProvider watchedProperties: ["value", "validationState", "resolve"] - containerStackId: updateAllExtruders ? Cura.ExtruderManager.extruderIds[defaultExtruderIndex] : Cura.MachineManager.activeMachine.id + containerStackId: updateAllExtruders ? Cura.ExtruderManager.globalStackExtruderIds[defaultExtruderIndex] : Cura.MachineManager.activeMachine.id } Connections