Prevent crash when cloud printer gets added while trying to connect to active printers

The cloud printers get added asynchronously, which could lead to a crash because the dict gets modified while we're iterating over it.

Fixes Sentry issue CURA-2EN.
This commit is contained in:
Ghostkeeper 2021-06-17 13:35:15 +02:00
parent 5252d53187
commit 788efcc83e
No known key found for this signature in database
GPG key ID: D2A8871EE34EC59A

View file

@ -399,7 +399,7 @@ class CloudOutputDeviceManager:
output_device_manager = CuraApplication.getInstance().getOutputDeviceManager()
stored_cluster_id = active_machine.getMetaDataEntry(self.META_CLUSTER_ID)
local_network_key = active_machine.getMetaDataEntry(self.META_NETWORK_KEY)
for device in self._remote_clusters.values():
for device in list(self._remote_clusters.values()): # Make a copy of the remote devices list, to prevent modifying the list while iterating, if a device gets added asynchronously.
if device.key == stored_cluster_id:
# Connect to it if the stored ID matches.
self._connectToOutputDevice(device, active_machine)