From bb8be051ffffa56a01093c9f3aaa80e84748568f Mon Sep 17 00:00:00 2001 From: Christian Kolset Date: Sun, 20 Sep 2026 11:31:07 -0600 Subject: Fix Signal name reset and orphaned references on device reconfigure Apply & Reconnect rebuilt a device's whole Signal list from hardware defaults on every call, silently discarding user/profile-set names, units, and colors even when pins hadn't changed. Add merge_signal_metadata() and call it from ArduinoDevice.remap_pins() and SerialDevice.reconfigure() to reapply the same fields ProfileManager already treats as user overrides, keyed by signal_id. Also close a related gap: removing a pin that a Channel/Plot/Control still referenced left it silently dangling, and SignalProcessor never pruned its latest-value cache, so a derived Channel kept computing off a permanently frozen stale reading. Add SignalProcessor. on_device_reconfigured() to purge that cache, reference_registry. find_references() for a console breadcrumb, and live "missing source" indicators on Plot traces and Channel blocks reusing ControlWidget's existing stale/QSS pattern. Also fixes ControlWidget._write() still enqueuing writes to a channel that no longer exists. Co-Authored-By: Claude Sonnet 5 --- ui/main_window.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'ui/main_window.py') diff --git a/ui/main_window.py b/ui/main_window.py index 0e21b2e..ba93121 100644 --- a/ui/main_window.py +++ b/ui/main_window.py @@ -720,6 +720,17 @@ class MainWindow(QMainWindow): self._status.setText(f"Device '{dev_id}' removed.") def _on_device_reconfigured(self, dev_id: str): + dev = self.registry.get_instance(dev_id) + if dev is not None: + current_ids = {s.signal_id for s in dev.info.signals} + removed_ids = self.processor.on_device_reconfigured(dev_id, current_ids) + if removed_ids: + from core.reference_registry import find_references + for sid in removed_ids: + refs = find_references(self, (dev_id, sid)) + if refs: + print(f"[Device '{dev_id}'] signal '{sid}' removed by reconfigure — " + f"still referenced by: {', '.join(refs)}") self.engine.on_device_reconfigured(dev_id) self._chart.refresh() if self._win_config: -- cgit v1.2.3