Previously there would always be one item in the updateableMachinesModel ("Create new"). This was moved to a button instead of being part of the model.

This fixes new machines being incorrectly created when a machine already exists.

CURA-9424
This commit is contained in:
Joey de l'Arago 2022-11-17 16:21:57 +01:00
parent da71983891
commit 4d2f6b9655

View file

@ -616,6 +616,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
# The machine included in the project file exists locally already, no need to change selected printers.
is_networked_machine = global_stack.hasNetworkedConnection()
is_abstract_machine = parseBool(existing_global_stack.getMetaDataEntry("is_abstract_machine", False))
self._dialog.setMachineToOverride(global_stack.getId())
elif self._dialog.updatableMachinesModel.count > 0:
# The machine included in the project file does not exist. There is another machine of the same type.
# This will always default to an abstract machine first.
@ -630,6 +631,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
machine_name = i18n_catalog.i18nc("@button", "Create new")
self._dialog.setIsAbstractMachine(False)
self._dialog.setIsNetworkedMachine(False)
self._dialog.setMachineToOverride(None)
self._dialog.setResolveStrategy("machine", "new")
self._dialog.setIsNetworkedMachine(is_networked_machine)
@ -730,7 +732,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
application.expandedCategoriesChanged.emit() # Notify the GUI of the change
# If there are no machines of the same type, create a new machine.
if self._resolve_strategies["machine"] != "override" or self._dialog.updatableMachinesModel.count <= 1:
if self._resolve_strategies["machine"] != "override" or self._dialog.updatableMachinesModel.count == 0:
# We need to create a new machine
machine_name = self._container_registry.uniqueName(self._machine_info.name)