From b7257ed37fcd0c6d4ca6d5a115f89ff8d72462de Mon Sep 17 00:00:00 2001 From: ables3000 Date: Tue, 16 Aug 2022 00:15:36 +0800 Subject: [PATCH] Fix show notification memory leak when content is object --- .../Notifications/WindowNotificationManager.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Avalonia.Controls/Notifications/WindowNotificationManager.cs b/src/Avalonia.Controls/Notifications/WindowNotificationManager.cs index 2449f4c15c..630276767a 100644 --- a/src/Avalonia.Controls/Notifications/WindowNotificationManager.cs +++ b/src/Avalonia.Controls/Notifications/WindowNotificationManager.cs @@ -102,15 +102,12 @@ namespace Avalonia.Controls.Notifications Content = content }; - if (notification != null) + notificationControl.NotificationClosed += (sender, args) => { - notificationControl.NotificationClosed += (sender, args) => - { - notification.OnClose?.Invoke(); + notification?.OnClose?.Invoke(); - _items?.Remove(sender); - }; - } + _items?.Remove(sender); + }; notificationControl.PointerPressed += (sender, args) => {