From 8756feff5d0fca8c96acd5a2a2fde65e52f86087 Mon Sep 17 00:00:00 2001 From: affederaffe <68356204+affederaffe@users.noreply.github.com> Date: Fri, 22 Dec 2023 07:11:57 +0100 Subject: [PATCH] Fix DBus Exception on window close (#13997) * Only disconnect from ibus when connected * Catch exception on Destroy when ime context is successfully created but doesn't actually exist --- .../DBusIme/DBusTextInputMethodBase.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.FreeDesktop/DBusIme/DBusTextInputMethodBase.cs b/src/Avalonia.FreeDesktop/DBusIme/DBusTextInputMethodBase.cs index 6cd24c49eb..158321acf5 100644 --- a/src/Avalonia.FreeDesktop/DBusIme/DBusTextInputMethodBase.cs +++ b/src/Avalonia.FreeDesktop/DBusIme/DBusTextInputMethodBase.cs @@ -179,12 +179,23 @@ namespace Avalonia.FreeDesktop.DBusIme _disposables.Add(d); } - public void Dispose() + public async void Dispose() { foreach(var d in _disposables) d.Dispose(); _disposables.Clear(); - _ = DisconnectAsync(); + if (!IsConnected) + return; + try + { + await DisconnectAsync(); + } + catch (Exception ex) + { + Logger.TryGet(LogEventLevel.Error, "IME") + ?.Log(this, "Error while destroying the context:\n" + ex); + } + _currentName = null; }