From a8310f1dab202a1effbb92705ae705ed1756fce0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Kaan=20K=C3=B6se?= Date: Thu, 9 Apr 2026 01:26:23 +0200 Subject: [PATCH] Fixing the leak in calendar mmode. --- .../Controls/Calendar/CalendarPeriodControl.xaml | 1 + .../Controls/Calendar/CalendarPeriodControl.xaml.cs | 7 +++++++ Wino.Mail.WinUI/Views/Calendar/CalendarPage.xaml.cs | 6 ++++++ Wino.Mail.WinUI/Views/WinoAppShell.xaml.cs | 2 ++ 4 files changed, 16 insertions(+) diff --git a/Wino.Mail.WinUI/Controls/Calendar/CalendarPeriodControl.xaml b/Wino.Mail.WinUI/Controls/Calendar/CalendarPeriodControl.xaml index d4712bf6..31b36a6e 100644 --- a/Wino.Mail.WinUI/Controls/Calendar/CalendarPeriodControl.xaml +++ b/Wino.Mail.WinUI/Controls/Calendar/CalendarPeriodControl.xaml @@ -11,6 +11,7 @@ xmlns:viewModels="using:Wino.Calendar.ViewModels.Data" x:Name="Root" SizeChanged="ControlSizeChanged" + Unloaded="ControlUnloaded" mc:Ignorable="d"> diff --git a/Wino.Mail.WinUI/Controls/Calendar/CalendarPeriodControl.xaml.cs b/Wino.Mail.WinUI/Controls/Calendar/CalendarPeriodControl.xaml.cs index 17391f9e..dbc973b0 100644 --- a/Wino.Mail.WinUI/Controls/Calendar/CalendarPeriodControl.xaml.cs +++ b/Wino.Mail.WinUI/Controls/Calendar/CalendarPeriodControl.xaml.cs @@ -324,6 +324,13 @@ public sealed partial class CalendarPeriodControl : UserControl, INotifyProperty }); } + private void ControlUnloaded(object sender, RoutedEventArgs e) + { + DetachCurrentItemsSource(); + _sizeRefreshTimer.Stop(); + _sizeRefreshTimer.Tick -= SizeRefreshTimerTick; + } + private void SizeRefreshTimerTick(DispatcherQueueTimer sender, object args) { sender.Stop(); diff --git a/Wino.Mail.WinUI/Views/Calendar/CalendarPage.xaml.cs b/Wino.Mail.WinUI/Views/Calendar/CalendarPage.xaml.cs index cc50529a..5cce241e 100644 --- a/Wino.Mail.WinUI/Views/Calendar/CalendarPage.xaml.cs +++ b/Wino.Mail.WinUI/Views/Calendar/CalendarPage.xaml.cs @@ -52,6 +52,12 @@ public sealed partial class CalendarPage : CalendarPageAbstract, ITitleBarSearch base.OnNavigatingFrom(e); } + public override void PrepareForClose() + { + DetachNavigationLifetimeEvents(); + base.PrepareForClose(); + } + protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); diff --git a/Wino.Mail.WinUI/Views/WinoAppShell.xaml.cs b/Wino.Mail.WinUI/Views/WinoAppShell.xaml.cs index 4f2767c7..2f06a996 100644 --- a/Wino.Mail.WinUI/Views/WinoAppShell.xaml.cs +++ b/Wino.Mail.WinUI/Views/WinoAppShell.xaml.cs @@ -168,6 +168,8 @@ public sealed partial class WinoAppShell : Views.Abstract.WinoAppShellAbstract, { ViewModel.StatePersistenceService.IsEventDetailsVisible = false; ViewModel.CalendarClient.Deactivate(); + WindowCleanupHelper.CleanupFrame(InnerShellFrame); + GC.Collect(); } else if (_activeMode == WinoApplicationMode.Contacts) {