From 4b3fda21e2459b4c73b842b4cd97abe1ecd18076 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 16 Oct 2020 16:09:37 +0200 Subject: [PATCH] Prevent duplicate adding of extruders The addMachineExtruders function assumes that this is a new printer (first time the printer is activated since a restart of Cura) and it needs to add the extruder stacks to it. However most of the time when we're switching, it's not to a new printer. If it's not a new printer, this function would get called anyway and we'd be adding the extruders multiple times. This then does a lot of unnecessary work and eventually fails a couple of calls deep. This change prevents it from adding the extruders if there are already extruders associated with the printer, thus preventing this unnecessary work (switch is faster) and preventing the error from happening. Discovered during work on CURA-7501. --- cura/Settings/MachineManager.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index 94a1869598..faccf2e474 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -336,7 +336,8 @@ class MachineManager(QObject): return # We're done here self._global_container_stack = global_stack - extruder_manager.addMachineExtruders(global_stack) + if not global_stack.extruderList: # First time we're activating this, there are no extruders yet. + extruder_manager.addMachineExtruders(global_stack) self._application.setGlobalContainerStack(global_stack) # Switch to the first enabled extruder