From 4a7206c8dcb2d201bfdbbe07c7ecbd59554b2e08 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 31 Mar 2026 01:05:07 +0000 Subject: [PATCH] fix: null _gatewayClient after dispose in OnSettingsSaved When OnSettingsSaved switches to node mode, _gatewayClient was disposed but not set to null. This caused guards like if (_gatewayClient == null) return; in ShowQuickSend, RunHealthCheckAsync, and ToggleChannel to pass instead of short-circuiting, potentially calling into a disposed object (ObjectDisposedException) or producing unexpected behaviour. The _nodeService field already followed the correct pattern (null first, then dispose). Apply the same pattern to _gatewayClient. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/OpenClaw.Tray.WinUI/App.xaml.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/OpenClaw.Tray.WinUI/App.xaml.cs b/src/OpenClaw.Tray.WinUI/App.xaml.cs index de0780f..68165d7 100644 --- a/src/OpenClaw.Tray.WinUI/App.xaml.cs +++ b/src/OpenClaw.Tray.WinUI/App.xaml.cs @@ -1606,6 +1606,7 @@ public partial class App : Application // Reconnect with new settings — mirror the startup if/else pattern // to avoid dual connections that cause gateway conflicts. _gatewayClient?.Dispose(); + _gatewayClient = null; var oldNodeService = _nodeService; _nodeService = null; try { oldNodeService?.Dispose(); } catch (Exception ex) { Logger.Warn($"Node dispose error: {ex.Message}"); }