From f0340c6d630dbf96319648c038e7c9cb0432a3b7 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 15 Jun 2016 09:50:05 +0200 Subject: [PATCH 1/2] Rework based on review CURA-1689 --- cura/ExtruderManager.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cura/ExtruderManager.py b/cura/ExtruderManager.py index da5887be61..159db42919 100644 --- a/cura/ExtruderManager.py +++ b/cura/ExtruderManager.py @@ -67,12 +67,14 @@ class ExtruderManager(QObject): self.activeExtruderChanged.emit() def getActiveExtruderStack(self): - try: - return self._extruder_trains[UM.Application.getInstance().getGlobalContainerStack().getBottom().getId()][str(self._active_extruder_index)] - except AttributeError: - return None - except KeyError: - return None + global_container_stack = UM.Application.getInstance().getGlobalContainerStack() + if global_container_stack: + global_definition_container = UM.Application.getInstance().getGlobalContainerStack().getBottom() + if global_definition_container: + if str(self._active_extruder_index) in self._extruder_trains[global_definition_container.getId()]: + return self._extruder_trains[global_definition_container.getId()][str(self._active_extruder_index)] + return self._extruder_trains[UM.Application.getInstance().getGlobalContainerStack().getBottom().getId()][str(self._active_extruder_index)] + ## Adds all extruders of a specific machine definition to the extruder # manager. From 7176c98d8a67358bb8f418cceff4ed86971d11d4 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 15 Jun 2016 10:21:06 +0200 Subject: [PATCH 2/2] Fixed stupid mistake with getting active extruder stack CURA-1689 --- cura/ExtruderManager.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cura/ExtruderManager.py b/cura/ExtruderManager.py index 159db42919..9be1d8dc53 100644 --- a/cura/ExtruderManager.py +++ b/cura/ExtruderManager.py @@ -71,9 +71,9 @@ class ExtruderManager(QObject): if global_container_stack: global_definition_container = UM.Application.getInstance().getGlobalContainerStack().getBottom() if global_definition_container: - if str(self._active_extruder_index) in self._extruder_trains[global_definition_container.getId()]: - return self._extruder_trains[global_definition_container.getId()][str(self._active_extruder_index)] - return self._extruder_trains[UM.Application.getInstance().getGlobalContainerStack().getBottom().getId()][str(self._active_extruder_index)] + if global_definition_container.getId() in self._extruder_trains: + if str(self._active_extruder_index) in self._extruder_trains[global_definition_container.getId()]: + return self._extruder_trains[global_definition_container.getId()][str(self._active_extruder_index)] ## Adds all extruders of a specific machine definition to the extruder