From c0a502f99c637898a59721907e2c824356d48ead Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Wed, 6 Dec 2017 11:47:31 +0100 Subject: [PATCH] Check if there is an active machine before doing anything else CURA-4680 --- cura/Settings/MachineManager.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index f1bb8b6648..253c5f793c 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -498,6 +498,11 @@ class MachineManager(QObject): @pyqtProperty("QVariantList", notify=activeVariantChanged) def activeVariantNames(self) -> List[str]: result = [] + + # it can happen when there is no active machine + if self._global_container_stack is None: + return result + active_stacks = ExtruderManager.getInstance().getActiveGlobalAndExtruderStacks() if active_stacks is not None: for stack in active_stacks: @@ -510,6 +515,11 @@ class MachineManager(QObject): @pyqtProperty("QVariantList", notify = activeMaterialChanged) def activeMaterialNames(self) -> List[str]: result = [] + + # it can happen when there is no active machine + if self._global_container_stack is None: + return result + active_stacks = ExtruderManager.getInstance().getActiveGlobalAndExtruderStacks() if active_stacks is not None: for stack in active_stacks: @@ -530,6 +540,11 @@ class MachineManager(QObject): @pyqtProperty("QVariantMap", notify = activeVariantChanged) def allActiveVariantIds(self) -> Dict[str, str]: result = {} + + # it can happen when there is no active machine + if self._global_container_stack is None: + return result + active_stacks = ExtruderManager.getInstance().getActiveExtruderStacks() if active_stacks is not None: #If we have a global stack. for stack in active_stacks: @@ -548,6 +563,11 @@ class MachineManager(QObject): @pyqtProperty("QVariantMap", notify = activeMaterialChanged) def allActiveMaterialIds(self) -> Dict[str, str]: result = {} + + # it can happen when there is no active machine + if self._global_container_stack is None: + return result + active_stacks = ExtruderManager.getInstance().getActiveExtruderStacks() result[self._global_container_stack.getId()] = self._global_container_stack.material.getId()