From da1a5d1be649673f922c0c13cd9fdae7caf0395e Mon Sep 17 00:00:00 2001 From: Kostas Karmas Date: Tue, 10 Dec 2019 14:44:31 +0100 Subject: [PATCH 1/3] Log error on failed machine creation An error message will be generated when machine creation fails while switching printer types in the printer configuration menu. CURA-6127 --- cura/Settings/MachineManager.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index de6e270a86..f8e609af77 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -1241,6 +1241,7 @@ class MachineManager(QObject): if not new_machine: new_machine = CuraStackBuilder.createMachine(machine_definition_id + "_sync", machine_definition_id) if not new_machine: + Logger.log("e", "Failed to create new machine when switching configuration.") return for metadata_key in self._global_container_stack.getMetaData(): From 2b6b7a1f815212b1bf022a1cbbf5f1401704799c Mon Sep 17 00:00:00 2001 From: Kostas Karmas Date: Fri, 13 Dec 2019 11:30:34 +0100 Subject: [PATCH 2/3] Fix lost settings on sync to diff printer type When syncing to a different printer type only the global user changes where kept, while the per-extruder user changes were not copied at all, since the extruder list is empty before the new machine becomes active. This commit fixes this problem by keeping a copy of the per-extruder user changes before the new machine (of different type) is activated. The copied user changes are then transfered to the new global stack after the new machine is set as active. CURA-6127 --- cura/Settings/MachineManager.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index f8e609af77..ece3e1ce92 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -1257,8 +1257,19 @@ class MachineManager(QObject): new_machine.setMetaDataEntry("hidden", False) self._global_container_stack.setMetaDataEntry("hidden", True) + # The new_machine only has the global user changes and not the per-extruder user changes (since it has an empty + # extruderList before it becomes active). Keep a temporary copy of the per-extruder user changes and transfer + # it to the user changes of the new machine after the new_machine becomes active. + per_extruder_user_changes = {} + for extruder_name, extruder_stack in self._global_container_stack.extruders.items(): + per_extruder_user_changes[extruder_name] = extruder_stack.userChanges + self.setActiveMachine(new_machine.getId()) + # Apply the per-extruder userChanges to the new_machine (which is of different type than the previous one). + for extruder_name in self._global_container_stack.extruders.keys(): + self._global_container_stack.extruders[extruder_name].setUserChanges(per_extruder_user_changes[extruder_name]) + @pyqtSlot(QObject) def applyRemoteConfiguration(self, configuration: PrinterConfigurationModel) -> None: if self._global_container_stack is None: From 409dc98299d15960df42c801e3ac3ae58a6e109a Mon Sep 17 00:00:00 2001 From: Kostas Karmas Date: Fri, 13 Dec 2019 15:00:22 +0100 Subject: [PATCH 3/3] Keep global settings on sync to diff printer type In addition to the per-extruder user changes, copy the global user changes to the new_machine. CURA-6127 --- cura/Settings/MachineManager.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index ece3e1ce92..989a92d8f9 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -1257,16 +1257,19 @@ class MachineManager(QObject): new_machine.setMetaDataEntry("hidden", False) self._global_container_stack.setMetaDataEntry("hidden", True) - # The new_machine only has the global user changes and not the per-extruder user changes (since it has an empty - # extruderList before it becomes active). Keep a temporary copy of the per-extruder user changes and transfer - # it to the user changes of the new machine after the new_machine becomes active. + # The new_machine does not contain user changes (global or per-extruder user changes). + # Keep a temporary copy of the global and per-extruder user changes and transfer them to the user changes + # of the new machine after the new_machine becomes active. + global_user_changes = self._global_container_stack.userChanges per_extruder_user_changes = {} for extruder_name, extruder_stack in self._global_container_stack.extruders.items(): per_extruder_user_changes[extruder_name] = extruder_stack.userChanges self.setActiveMachine(new_machine.getId()) - # Apply the per-extruder userChanges to the new_machine (which is of different type than the previous one). + # Apply the global and per-extruder userChanges to the new_machine (which is of different type than the + # previous one). + self._global_container_stack.setUserChanges(global_user_changes) for extruder_name in self._global_container_stack.extruders.keys(): self._global_container_stack.extruders[extruder_name].setUserChanges(per_extruder_user_changes[extruder_name])