From 486df8acbadadcbc6ab462e29ece840ddacc65e6 Mon Sep 17 00:00:00 2001 From: deryaza <46353085+deryaza@users.noreply.github.com> Date: Thu, 11 Jun 2026 18:44:02 +0400 Subject: [PATCH] Fix mishandled cancellation in DBusTextInputMethodBase (#21527) * Fix mishandled cancellation in DBusTextInputMethodBase * Revert "Fix mishandled cancellation in DBusTextInputMethodBase" This reverts commit ac18b6d878d08abb8bd19c12fd6cb933b3e37da6. * review --- .../DBusIme/DBusTextInputMethodBase.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Avalonia.FreeDesktop/DBusIme/DBusTextInputMethodBase.cs b/src/Avalonia.FreeDesktop/DBusIme/DBusTextInputMethodBase.cs index cfd28b29aa..236276f805 100644 --- a/src/Avalonia.FreeDesktop/DBusIme/DBusTextInputMethodBase.cs +++ b/src/Avalonia.FreeDesktop/DBusIme/DBusTextInputMethodBase.cs @@ -64,9 +64,9 @@ namespace Avalonia.FreeDesktop.DBusIme _watchCts = new CancellationTokenSource(); var cancellationToken = _watchCts.Token; foreach (var name in _knownNames) - WatchNameAsync(name); + _ = WatchNameAsync(name); - async void WatchNameAsync(string name) + async Task WatchNameAsync(string name) { try { @@ -99,10 +99,13 @@ namespace Avalonia.FreeDesktop.DBusIme OnOwnerChanged(name, owner); } } - catch (Exception e) when (!cancellationToken.IsCancellationRequested) + catch (Exception e) { - Logger.TryGet(LogEventLevel.Error, LogArea.FreeDesktopPlatform) - ?.Log(this, $"WatchNameOwner for '{name}' failed: {e}"); + if (!cancellationToken.IsCancellationRequested) + { + Logger.TryGet(LogEventLevel.Error, LogArea.FreeDesktopPlatform) + ?.Log(this, $"WatchNameOwner for '{name}' failed: {e}"); + } } } }