From 19b3dc335ad08355ac413c9d173e8d6cc9ab9bc4 Mon Sep 17 00:00:00 2001 From: Daniil Pavliuchyk Date: Tue, 24 Jan 2023 13:24:24 +0200 Subject: [PATCH] Don't process events when TopLevel is disposed. --- src/Avalonia.Controls/TopLevel.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Avalonia.Controls/TopLevel.cs b/src/Avalonia.Controls/TopLevel.cs index ff241dce7a..c2e997464c 100644 --- a/src/Avalonia.Controls/TopLevel.cs +++ b/src/Avalonia.Controls/TopLevel.cs @@ -581,12 +581,21 @@ namespace Avalonia.Controls /// The event args. private void HandleInput(RawInputEventArgs e) { - if (e is RawPointerEventArgs pointerArgs) + if (PlatformImpl != null) { - pointerArgs.InputHitTestResult = this.InputHitTest(pointerArgs.Position); - } + if (e is RawPointerEventArgs pointerArgs) + { + pointerArgs.InputHitTestResult = this.InputHitTest(pointerArgs.Position); + } - _inputManager?.ProcessInput(e); + _inputManager?.ProcessInput(e); + } + else + { + Logger.TryGet(LogEventLevel.Warning, LogArea.Control)?.Log( + this, + "PlatformImpl is null, couldn't handle input."); + } } private void SceneInvalidated(object? sender, SceneInvalidatedEventArgs e)