mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 07:27:29 -06:00
Update _remote_clusters dict when cloud printer is removed from Cura
CURA-7457
This commit is contained in:
parent
be814535e9
commit
d0534c0476
1 changed files with 16 additions and 0 deletions
|
@ -9,6 +9,7 @@ from PyQt5.QtNetwork import QNetworkReply
|
||||||
from UM import i18nCatalog
|
from UM import i18nCatalog
|
||||||
from UM.Logger import Logger # To log errors talking to the API.
|
from UM.Logger import Logger # To log errors talking to the API.
|
||||||
from UM.Message import Message
|
from UM.Message import Message
|
||||||
|
from UM.Settings.Interfaces import ContainerInterface
|
||||||
from UM.Signal import Signal
|
from UM.Signal import Signal
|
||||||
from cura.API import Account
|
from cura.API import Account
|
||||||
from cura.API.Account import SyncState
|
from cura.API.Account import SyncState
|
||||||
|
@ -49,6 +50,8 @@ class CloudOutputDeviceManager:
|
||||||
|
|
||||||
self._syncing = False
|
self._syncing = False
|
||||||
|
|
||||||
|
CuraApplication.getInstance().getContainerRegistry().containerRemoved.connect(self._printerRemoved)
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
"""Starts running the cloud output device manager, thus periodically requesting cloud data."""
|
"""Starts running the cloud output device manager, thus periodically requesting cloud data."""
|
||||||
|
|
||||||
|
@ -287,3 +290,16 @@ class CloudOutputDeviceManager:
|
||||||
output_device_manager = CuraApplication.getInstance().getOutputDeviceManager()
|
output_device_manager = CuraApplication.getInstance().getOutputDeviceManager()
|
||||||
if device.key not in output_device_manager.getOutputDeviceIds():
|
if device.key not in output_device_manager.getOutputDeviceIds():
|
||||||
output_device_manager.addOutputDevice(device)
|
output_device_manager.addOutputDevice(device)
|
||||||
|
|
||||||
|
def _printerRemoved(self, container: ContainerInterface) -> None:
|
||||||
|
"""
|
||||||
|
Callback connected to the containerRemoved signal. Invoked when a cloud printer is removed from Cura to remove
|
||||||
|
the printer's reference from the _remote_clusters.
|
||||||
|
|
||||||
|
:param container: The ContainerInterface passed to this function whenever the ContainerRemoved signal is emitted
|
||||||
|
:return: None
|
||||||
|
"""
|
||||||
|
if isinstance(container, GlobalStack):
|
||||||
|
printer_clusters_map = {cluster.name: cluster_id for cluster_id, cluster in self._remote_clusters.items()}
|
||||||
|
if container.name in printer_clusters_map:
|
||||||
|
del self._remote_clusters[printer_clusters_map[container.name]]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue