From b6e087259be375c9f841959f986bdb2ccb9cfca0 Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 30 May 2024 16:12:28 +0800 Subject: [PATCH] fix: memory leak caused by animation --- src/Views/Blame.axaml | 5 +---- src/Views/FileHistories.axaml | 10 ++++------ src/Views/Histories.axaml | 7 ++----- src/Views/LoadingIcon.axaml | 9 +++++++++ src/Views/LoadingIcon.axaml.cs | 27 +++++++++++++++++++++++++++ src/Views/Statistics.axaml | 10 ++++------ src/Views/WorkingCopy.axaml | 10 +++------- 7 files changed, 50 insertions(+), 28 deletions(-) create mode 100644 src/Views/LoadingIcon.axaml create mode 100644 src/Views/LoadingIcon.axaml.cs diff --git a/src/Views/Blame.axaml b/src/Views/Blame.axaml index 06bd43e0..3befbadb 100644 --- a/src/Views/Blame.axaml +++ b/src/Views/Blame.axaml @@ -84,10 +84,7 @@ - + diff --git a/src/Views/FileHistories.axaml b/src/Views/FileHistories.axaml index a2557275..a52445f6 100644 --- a/src/Views/FileHistories.axaml +++ b/src/Views/FileHistories.axaml @@ -106,12 +106,10 @@ BorderThickness="1,0,0,0" BorderBrush="{DynamicResource Brush.Border2}"/> - + diff --git a/src/Views/Histories.axaml b/src/Views/Histories.axaml index 3c4e1c6a..650d52e2 100644 --- a/src/Views/Histories.axaml +++ b/src/Views/Histories.axaml @@ -135,11 +135,8 @@ IsHitTestVisible="False" ClipToBounds="True"/> - + + + + diff --git a/src/Views/LoadingIcon.axaml.cs b/src/Views/LoadingIcon.axaml.cs new file mode 100644 index 00000000..95f35efa --- /dev/null +++ b/src/Views/LoadingIcon.axaml.cs @@ -0,0 +1,27 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Interactivity; + +namespace SourceGit.Views +{ + public partial class LoadingIcon : UserControl + { + public LoadingIcon() + { + IsHitTestVisible = false; + InitializeComponent(); + } + + protected override void OnLoaded(RoutedEventArgs e) + { + base.OnLoaded(e); + target.Classes.Add("rotating"); + } + + protected override void OnUnloaded(RoutedEventArgs e) + { + base.OnUnloaded(e); + target.Classes.Clear(); + } + } +} diff --git a/src/Views/Statistics.axaml b/src/Views/Statistics.axaml index b0d73bec..d3e552ad 100644 --- a/src/Views/Statistics.axaml +++ b/src/Views/Statistics.axaml @@ -180,11 +180,9 @@ - + diff --git a/src/Views/WorkingCopy.axaml b/src/Views/WorkingCopy.axaml index 5aa72ff7..fd5f8bb4 100644 --- a/src/Views/WorkingCopy.axaml +++ b/src/Views/WorkingCopy.axaml @@ -24,7 +24,7 @@ - +