From 89810ce95b972dca55737a0e4620dbea453281d7 Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Tue, 26 May 2026 13:36:26 +0200 Subject: [PATCH] gui_client: clear plot data on connect/reconnect Add PlotTab.clear_data() which resets _series and _units, then redraws. Called in MainWindow._connect() before opening the socket so stale data from a previous session never mingles with fresh history from the server. Co-Authored-By: Claude Sonnet 4.6 --- gui_client.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gui_client.py b/gui_client.py index 0a371c8..3dad8f1 100644 --- a/gui_client.py +++ b/gui_client.py @@ -518,7 +518,12 @@ class PlotTab(QWidget): for j, key in enumerate(self._traces[plot_idx]): self._add_chip(plot_idx, key, j) - # ── public update called on every new snapshot ──────────────────────────── + # ── public API ──────────────────────────────────────────────────────────── + + def clear_data(self): + self._series.clear() + self._units.clear() + self._redraw() def update(self, snapshot: dict): ts_raw = snapshot.get("ts", "") @@ -680,6 +685,7 @@ class MainWindow(QMainWindow): self._record_count = 0 def _connect(self, host: str, port: int): + self._plot.clear_data() err = self._reader.connect_to(host, port) if err: self._connector.set_disconnected(err)