Skip to content

Commit

Permalink
Fix DBus Exception on window close (AvaloniaUI#13997)
Browse files Browse the repository at this point in the history
* Only disconnect from ibus when connected

* Catch exception on Destroy when ime context is successfully created but doesn't actually exist
  • Loading branch information
affederaffe authored Dec 22, 2023
1 parent 960db26 commit 8756fef
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/Avalonia.FreeDesktop/DBusIme/DBusTextInputMethodBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,23 @@ protected void AddDisposable(IDisposable? d)
_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;
}

Expand Down

0 comments on commit 8756fef

Please sign in to comment.