Check if there is an active machine before doing anything else

CURA-4680
This commit is contained in:
Lipu Fei 2017-12-06 11:47:31 +01:00
parent aa727df525
commit c0a502f99c

View file

@ -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()