Skip to content

Commit 83bc664

Browse files
committed
Fix memory leak in ResultViewModel
1 parent 94df8d9 commit 83bc664

File tree

2 files changed

+5
-38
lines changed

2 files changed

+5
-38
lines changed

Flow.Launcher/ResultListBox.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@
175175
Margin="0,0,0,1"
176176
VerticalAlignment="Bottom"
177177
DockPanel.Dock="Left"
178-
FontSize="{Binding ResultItemFontSize, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
178+
FontSize="{Binding Settings.ResultItemFontSize, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
179179
IsEnabled="False"
180180
Style="{DynamicResource ItemTitleStyle}"
181181
Text="{Binding Result.Title}"
@@ -194,7 +194,7 @@
194194
Grid.Row="1"
195195
Margin="0,1,0,0"
196196
VerticalAlignment="Top"
197-
FontSize="{Binding ResultSubItemFontSize, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
197+
FontSize="{Binding Settings.ResultSubItemFontSize, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
198198
IsEnabled="False"
199199
Style="{DynamicResource ItemSubTitleStyle}"
200200
Text="{Binding Result.SubTitle}"
@@ -224,7 +224,7 @@
224224
<Style TargetType="{x:Type ListBoxItem}">
225225
<EventSetter Event="MouseEnter" Handler="OnMouseEnter" />
226226
<EventSetter Event="MouseMove" Handler="OnMouseMove" />
227-
<Setter Property="Height" Value="{Binding ItemHeightSize, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
227+
<Setter Property="Height" Value="{Binding Settings.ItemHeightSize, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
228228
<Setter Property="Margin" Value="0" />
229229
<Setter Property="Padding" Value="0" />
230230
<Setter Property="BorderThickness" Value="0" />

Flow.Launcher/ViewModel/ResultViewModel.cs

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,6 @@ public ResultViewModel(Result result, Settings settings)
2121
{
2222
Settings = settings;
2323

24-
Settings.PropertyChanged += (_, args) =>
25-
{
26-
switch (args.PropertyName)
27-
{
28-
case nameof(Settings.ItemHeightSize):
29-
OnPropertyChanged(nameof(ItemHeightSize));
30-
break;
31-
case nameof(Settings.ResultItemFontSize):
32-
OnPropertyChanged(nameof(ResultItemFontSize));
33-
break;
34-
case nameof(Settings.ResultSubItemFontSize):
35-
OnPropertyChanged(nameof(ResultSubItemFontSize));
36-
break;
37-
}
38-
};
39-
4024

4125
if (result == null)
4226
{
@@ -46,7 +30,7 @@ public ResultViewModel(Result result, Settings settings)
4630

4731
if (Result.Glyph is { FontFamily: not null } glyph)
4832
{
49-
// Checks if it's a system installed font, which does not require path to be provided.
33+
// Checks if it's a system installed font, which does not require path to be provided.
5034
if (glyph.FontFamily.EndsWith(".ttf") || glyph.FontFamily.EndsWith(".otf"))
5135
{
5236
string fontFamilyPath = glyph.FontFamily;
@@ -81,7 +65,7 @@ public ResultViewModel(Result result, Settings settings)
8165

8266
}
8367

84-
private Settings Settings { get; }
68+
public Settings Settings { get; }
8569

8670
public Visibility ShowOpenResultHotkey =>
8771
Settings.ShowOpenResultHotkey ? Visibility.Visible : Visibility.Collapsed;
@@ -136,23 +120,6 @@ public double IconRadius
136120

137121
}
138122

139-
public double ItemHeightSize
140-
{
141-
get => Settings.ItemHeightSize;
142-
set => Settings.ItemHeightSize = value;
143-
}
144-
145-
public double ResultItemFontSize
146-
{
147-
get => Settings.ResultItemFontSize;
148-
set => Settings.ResultItemFontSize = value;
149-
}
150-
151-
public double ResultSubItemFontSize
152-
{
153-
get => Settings.ResultSubItemFontSize;
154-
set => Settings.ResultSubItemFontSize = value;
155-
}
156123
public Visibility ShowGlyph
157124
{
158125
get

0 commit comments

Comments
 (0)