Fix case where both a "normal" and an "abstract" ouput device could be active

CURA-8463
This commit is contained in:
Jaime van Kessel 2022-08-31 10:27:52 +02:00
parent dd5981d85e
commit 5ff07b00d0
No known key found for this signature in database
GPG key ID: C85F7A3AF1BAA7C4

View file

@ -64,7 +64,6 @@ class CloudOutputDeviceManager:
self._running = False
self._syncing = False
CuraApplication.getInstance().getContainerRegistry().containerRemoved.connect(self._printerRemoved)
def start(self):
@ -375,7 +374,6 @@ class CloudOutputDeviceManager:
def _connectToActiveMachine(self) -> None:
"""Callback for when the active machine was changed by the user"""
active_machine = CuraApplication.getInstance().getGlobalContainerStack()
if not active_machine:
return
@ -383,7 +381,6 @@ class CloudOutputDeviceManager:
# Check if we should directly connect with a "normal" CloudOutputDevice or that we should connect to an
# 'abstract' one
output_device_manager = CuraApplication.getInstance().getOutputDeviceManager()
if active_machine.getMetaDataEntry("is_abstract_machine") != "True":
stored_cluster_id = active_machine.getMetaDataEntry(self.META_CLUSTER_ID)
local_network_key = active_machine.getMetaDataEntry(self.META_NETWORK_KEY)
@ -399,10 +396,11 @@ class CloudOutputDeviceManager:
elif device.key in output_device_manager.getOutputDeviceIds():
# Remove device if it is not meant for the active machine.
output_device_manager.removeOutputDevice(device.key)
else: # Abstract it is!
# Update state of all abstract output devices
remote_abstract_cluster_copy: List[CloudOutputDevice] = list(self._abstract_clusters.values())
for device in remote_abstract_cluster_copy:
if device.printerType == active_machine.definition.getId():
if device.printerType == active_machine.definition.getId() and parseBool(active_machine.getMetaDataEntry("is_abstract_machine", False)):
self._connectToAbstractOutputDevice(device, active_machine)
elif device.key in output_device_manager.getOutputDeviceIds():
output_device_manager.removeOutputDevice(device.key)