mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Account for the fact that createMachine can return None
Contributes to issue CURA-5337. See also #3787.
This commit is contained in:
parent
f828c135f8
commit
624bbbeb4a
2 changed files with 6 additions and 3 deletions
|
@ -1236,7 +1236,7 @@ class MachineManager(QObject):
|
||||||
## Given a printer definition name, select the right machine instance. In case it doesn't exist, create a new
|
## Given a printer definition name, select the right machine instance. In case it doesn't exist, create a new
|
||||||
# instance with the same network key.
|
# instance with the same network key.
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
def switchPrinterType(self, machine_name: str):
|
def switchPrinterType(self, machine_name: str) -> None:
|
||||||
# Don't switch if the user tries to change to the same type of printer
|
# Don't switch if the user tries to change to the same type of printer
|
||||||
if self.activeMachineDefinitionName == machine_name:
|
if self.activeMachineDefinitionName == machine_name:
|
||||||
return
|
return
|
||||||
|
@ -1247,6 +1247,8 @@ class MachineManager(QObject):
|
||||||
# If there is no machine, then create a new one and set it to the non-hidden instance
|
# If there is no machine, then create a new one and set it to the non-hidden instance
|
||||||
if not new_machine:
|
if not new_machine:
|
||||||
new_machine = CuraStackBuilder.createMachine(machine_definition_id + "_sync", machine_definition_id)
|
new_machine = CuraStackBuilder.createMachine(machine_definition_id + "_sync", machine_definition_id)
|
||||||
|
if not new_machine:
|
||||||
|
return
|
||||||
new_machine.addMetaDataEntry("um_network_key", self.activeMachineNetworkKey)
|
new_machine.addMetaDataEntry("um_network_key", self.activeMachineNetworkKey)
|
||||||
new_machine.addMetaDataEntry("connect_group_name", self.activeMachineNetworkGroupName)
|
new_machine.addMetaDataEntry("connect_group_name", self.activeMachineNetworkGroupName)
|
||||||
new_machine.addMetaDataEntry("hidden", False)
|
new_machine.addMetaDataEntry("hidden", False)
|
||||||
|
|
|
@ -606,9 +606,10 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
||||||
machine_name = self._container_registry.uniqueName(self._machine_info.name)
|
machine_name = self._container_registry.uniqueName(self._machine_info.name)
|
||||||
|
|
||||||
global_stack = CuraStackBuilder.createMachine(machine_name, self._machine_info.definition_id)
|
global_stack = CuraStackBuilder.createMachine(machine_name, self._machine_info.definition_id)
|
||||||
extruder_stack_dict = global_stack.extruders
|
if global_stack: #Only switch if creating the machine was successful.
|
||||||
|
extruder_stack_dict = global_stack.extruders
|
||||||
|
|
||||||
self._container_registry.addContainer(global_stack)
|
self._container_registry.addContainer(global_stack)
|
||||||
else:
|
else:
|
||||||
# Find the machine
|
# Find the machine
|
||||||
global_stack = self._container_registry.findContainerStacks(name = self._machine_info.name, type = "machine")[0]
|
global_stack = self._container_registry.findContainerStacks(name = self._machine_info.name, type = "machine")[0]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue