Skip to content

Commit

Permalink
Fix crash on double disposal on CarouselToken
Browse files Browse the repository at this point in the history
  • Loading branch information
neon-nyan committed Jun 29, 2024
1 parent 53f01a9 commit 9e55c14
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions CollapseLauncher/XAMLs/MainApp/Pages/HomePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public sealed partial class HomePage
{
#region Properties
private GamePresetProperty CurrentGameProperty { get; set; }
private CancellationTokenSource PageToken { get; set; }
private CancellationTokenSourceWrapper PageToken { get; set; }
private CancellationTokenSourceWrapper CarouselToken { get; set; }

private int barWidth;
Expand Down Expand Up @@ -145,7 +145,7 @@ private async void StartLoadedRoutine(object sender, RoutedEventArgs e)
// HACK: Fix random crash by manually load the XAML part
// But first, let it initialize its properties.
CurrentGameProperty = GamePropertyVault.GetCurrentGameProperty();
PageToken = new CancellationTokenSource();
PageToken = new CancellationTokenSourceWrapper();
CarouselToken = new CancellationTokenSourceWrapper();

this.InitializeComponent();
Expand Down Expand Up @@ -247,8 +247,8 @@ private async void StartLoadedRoutine(object sender, RoutedEventArgs e)
private void Page_Unloaded(object sender, RoutedEventArgs e)
{
IsPageUnload = true;
PageToken.Cancel();
CarouselToken.Cancel();
if (!PageToken.IsCancelled) PageToken.Cancel();
if (!CarouselToken.IsCancelled) CarouselToken.Cancel();
}
#endregion

Expand Down

0 comments on commit 9e55c14

Please sign in to comment.