Skip to content

Commit

Permalink
perf: Fix RatingControlPage memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
Youssef1313 committed Jan 15, 2024
1 parent 5b2d3eb commit fbc6bea
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@ namespace SampleControl.Entities
[DebuggerDisplay("{" + nameof(ControlName) + "}")]
public partial class SampleChooserContent : INotifyPropertyChanged
{
// Keep all property getters and setters public to avoid issues when serializing/deserializing recent samples
// See https://github.com/unoplatform/uno/issues/15059#issuecomment-1891551501
public string ControlName { get; set; }
public Type ViewModelType { get; set; }
public Type ControlType { get; set; }
public string[] Categories { get; set; }
public string CategoriesString => Categories?.JoinBy(", ");
public string Description { get; set; }
public string QueryString => $"?sample={Categories.FirstOrDefault() ?? ""}/{ControlName}";
public bool IgnoreInSnapshotTests { get; internal set; }
public bool IsManualTest { get; internal set; }
public bool UsesFrame { get; internal set; }
public bool IgnoreInSnapshotTests { get; set; }
public bool IsManualTest { get; set; }
public bool UsesFrame { get; set; }

bool _isFavorite;
public bool IsFavorite
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

<StackPanel Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Center" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<!-- this guy is out of the Scroller because it's where I do panning tests: [and having nested pannable things is NOT WHAT SHOULD BE DONE!] -->
<muxcontrols:RatingControl x:Name="TestRatingControl" AutomationProperties.Name="TestRatingControl" Loaded="TestRatingControl_Loaded" PlaceholderValue="2.5"/>
<!-- Uno specific: TestRatingControl_Unloaded -->
<muxcontrols:RatingControl x:Name="TestRatingControl" AutomationProperties.Name="TestRatingControl" Loaded="TestRatingControl_Loaded" Unloaded="TestRatingControl_Unloaded" PlaceholderValue="2.5"/>
<ScrollViewer Height="500" Grid.Column="0">
<StackPanel x:Name="mainStackPanel" HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock Text="Test Not Started" x:Name="TestTextBlockControl" AutomationProperties.Name="TestTextBlockControl"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,9 @@ DependencyObject SearchVisualTree(DependencyObject root, string name)
return child;
}


protected
#if !WINAPPSDK
internal
#endif
override void OnNavigatingFrom(NavigatingCancelEventArgs e)
// Uno specific: Unlike WinUI, we unsubscribe on Unloaded because we don't get OnNavigatedFrom.
// See point #2 in https://github.com/unoplatform/uno/issues/15059#issuecomment-1891551501
private void TestRatingControl_Unloaded(object sender, RoutedEventArgs e)
{
_dt.Tick -= DispatcherTimer_Tick; // prevent leaks since the dispatcher holds a pointer to this
}
Expand Down

0 comments on commit fbc6bea

Please sign in to comment.