fix(device_inputs): on_device_update additional _destroyed safeguard

This commit is contained in:
2026-05-20 19:19:17 +02:00
parent 397f53b2a1
commit 47351bbde7
2 changed files with 17 additions and 6 deletions
@@ -191,6 +191,13 @@ class DeviceComboBox(BECWidget, QComboBox):
if self.config.autocomplete:
self.autocomplete = True
self._callback_id = self.bec_dispatcher.client.callbacks.register(
EventType.DEVICE_UPDATE, self.on_device_update
)
self.device_config_update.connect(
self.update_devices_from_filters, Qt.ConnectionType.QueuedConnection
)
if available_devices is not None:
self.set_available_devices(available_devices)
@@ -216,12 +223,6 @@ class DeviceComboBox(BECWidget, QComboBox):
else:
self.setCurrentText("")
self._callback_id = self.bec_dispatcher.client.callbacks.register(
EventType.DEVICE_UPDATE, self.on_device_update
)
self.device_config_update.connect(
self.update_devices_from_filters, Qt.ConnectionType.QueuedConnection
)
self.currentTextChanged.connect(self.check_validity)
self.check_validity(self.currentText())
@@ -257,6 +258,9 @@ class DeviceComboBox(BECWidget, QComboBox):
@SafeSlot()
def update_devices_from_filters(self):
"""Refresh the available device list from current device/readout/signal filters."""
if self._callback_id is None or getattr(self, "_destroyed", False):
return
self.config.device_filter = [entry.value for entry in self.device_filter]
self.config.readout_filter = [entry.value for entry in self.readout_filter]
self.config.signal_class_filter = self.signal_class_filter
@@ -491,6 +495,8 @@ class DeviceComboBox(BECWidget, QComboBox):
action: Device update action emitted by BEC.
content: Device update payload. Currently unused.
"""
if self._callback_id is None or getattr(self, "_destroyed", False):
return
if action in ["add", "remove", "reload"]:
self.device_config_update.emit()
@@ -211,6 +211,9 @@ class SignalComboBox(BECWidget, QComboBox):
content: Optional callback payload from BEC device updates. Currently unused.
metadata: Optional callback metadata from BEC device updates. Currently unused.
"""
if self._device_update_register is None or getattr(self, "_destroyed", False):
return
self.config.signal_filter = [kind.name for kind in self.signal_filter]
if self._signal_class_filter:
@@ -253,6 +256,8 @@ class SignalComboBox(BECWidget, QComboBox):
def on_device_update(self, action: str, content: dict) -> None:
"""Refresh filters when BEC reports device configuration changes."""
if self._device_update_register is None or getattr(self, "_destroyed", False):
return
if action in ["add", "remove", "reload"]:
self.device_config_update.emit()