Skip to content

Commit 927995c

Browse files
committed
Memory leakage on modus controls #452
1 parent ab4993a commit 927995c

10 files changed

Lines changed: 28 additions & 40 deletions

File tree

Trimble.Modus.Components/Controls/Button/TMButton.xaml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,7 @@
77
xmlns:constants="clr-namespace:Trimble.Modus.Components.Constant"
88
xmlns:converters="clr-namespace:Trimble.Modus.Components.Converters"
99
HorizontalOptions="Start">
10-
<ContentView.Resources>
11-
<ResourceDictionary>
12-
<!--<ResourceDictionary.MergedDictionaries>
13-
<local:TMButtonStyles></local:TMButtonStyles>
14-
</ResourceDictionary.MergedDictionaries>-->
15-
<converters:ImageNullOrEmptyBoolConverter x:Key="ImageNullOrEmptyBoolConverter" />
16-
<converters:StringNotNullOrEmptyBoolConverter x:Key="StringNotNullOrEmptyBoolConverter" />
17-
</ResourceDictionary>
18-
</ContentView.Resources>
10+
1911
<Border Padding="0"
2012
BindingContext="{x:Reference tmButton}"
2113
x:Name="buttonFrame"

Trimble.Modus.Components/Controls/DropDown/TMDropDown.xaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@
77
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
88
x:Class="Trimble.Modus.Components.TMDropDown"
99
xmlns:converters="clr-namespace:Trimble.Modus.Components.Converters">
10-
<ContentView.Resources>
11-
<ResourceDictionary>
12-
<converters:StringNotNullOrEmptyBoolConverter x:Key="StringNotNullOrEmptyBoolConverter" />
13-
</ResourceDictionary>
14-
</ContentView.Resources>
1510
<VerticalStackLayout BindingContext="{x:Reference dropDown}">
1611
<local:ControlLabel TitleText="{Binding TitleText}"
1712
IsRequired="{Binding IsRequired}"

Trimble.Modus.Components/Controls/DropDown/TMDropDown.xaml.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,6 @@ public TMDropDown()
135135
previousSelection = null;
136136
InitializeComponent();
137137
this.SetDynamicResource(StyleProperty, "DefaultStyle");
138-
PopupService.Instance.Dismissed += OnPopupRemoved;
139-
this.Unloaded += OnUnloaded;
140138
}
141139
#endregion
142140

@@ -368,7 +366,6 @@ private void TapGestureRecognizer_Tapped(object sender, TappedEventArgs e)
368366
Open();
369367
}
370368
}
371-
372369
protected override void OnParentSet()
373370
{
374371
base.OnParentSet();
@@ -383,17 +380,10 @@ protected override void OnHandlerChanged()
383380

384381
public void Dispose()
385382
{
386-
PopupService.Instance.Dismissed -= OnPopupRemoved;
387-
this.Unloaded -= OnUnloaded;
388383
SelectionChanged = null;
389384
SelectionChangedCommand = null;
390385
ItemsSource = null;
391386
dropDownContents = null;
392387
previousSelection = null;
393388
}
394-
395-
private void OnUnloaded(object sender, EventArgs e)
396-
{
397-
Dispose();
398-
}
399389
}

Trimble.Modus.Components/Controls/Label/ControlLabel.xaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@
55
xmlns:local="clr-namespace:Trimble.Modus.Components;assembly=Trimble.Modus.Components"
66
x:Class="Trimble.Modus.Components.ControlLabel"
77
x:Name="controlLabelView">
8-
<ContentView.Resources>
9-
<ResourceDictionary>
10-
11-
<toolkit:IsStringNotNullOrEmptyConverter x:Key="IsStringNotNullOrEmptyConverter" />
12-
</ResourceDictionary>
13-
</ContentView.Resources>
148
<Grid x:Name="view"
159
BindingContext="{x:Reference controlLabelView}"
1610
ColumnSpacing="6"

Trimble.Modus.Components/Controls/TMInput/BaseInput.xaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
xmlns:converters="clr-namespace:Trimble.Modus.Components.Converters">
88

99
<ContentView.Resources>
10-
<ResourceDictionary>
11-
<converters:StringNotNullOrEmptyBoolConverter x:Key="StringNotNullOrEmptyBoolConverter" />
12-
</ResourceDictionary>
1310
<ControlTemplate x:Key="InputTemplate">
1411
<Grid x:Name="tmInputContainer"
1512
RowDefinitions="auto,auto,auto"

Trimble.Modus.Components/Controls/TMInput/TMInput.xaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@
99
xmlns:controls="clr-namespace:Trimble.Modus.Components"
1010
x:Name="singleInput">
1111

12-
<base:BaseInput.Resources>
13-
<converters:InverseBoolConverter x:Key="InverseBoolConverter" />
14-
<converters:AllTrueConverter x:Key="AllTrueConverter" />
15-
</base:BaseInput.Resources>
16-
1712
<Grid ColumnDefinitions="auto,*,auto"
1813
ColumnSpacing="0"
1914
RowSpacing="0"

Trimble.Modus.Components/Helpers/ThemeManager.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ public static void Initialize(ModusConfig appConfig = null)
2323

2424
public static void RegisterStyles()
2525
{
26-
Application.Current.Resources.MergedDictionaries.Add(new ModusStyles());
26+
Application.Current.Resources.MergedDictionaries.Add(new ModusStyles());
27+
Application.Current.Resources.MergedDictionaries.Add(new ConvertersDictionary());
2728
}
2829

2930
private static void UpdateColorsDictionary(ModusConfig appConfig = null)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ResourceDictionary xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
x:Class="Trimble.Modus.Components.Styles.ConvertersDictionary"
5+
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
6+
xmlns:converters="clr-namespace:Trimble.Modus.Components.Converters;assembly=Trimble.Modus.Components">
7+
<toolkit:IsStringNotNullOrEmptyConverter x:Key="IsStringNotNullOrEmptyConverter" />
8+
<converters:InverseBoolConverter x:Key="InverseBoolConverter" />
9+
<converters:AllTrueConverter x:Key="AllTrueConverter" />
10+
<converters:ImageNullOrEmptyBoolConverter x:Key="ImageNullOrEmptyBoolConverter" />
11+
<converters:StringNotNullOrEmptyBoolConverter x:Key="StringNotNullOrEmptyBoolConverter" />
12+
</ResourceDictionary>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Trimble.Modus.Components.Styles;
2+
3+
public partial class ConvertersDictionary : ResourceDictionary
4+
{
5+
public ConvertersDictionary()
6+
{
7+
InitializeComponent();
8+
}
9+
}

Trimble.Modus.Components/Trimble.Modus.Components.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
2828
<PackageId>Trimble.Modus.Components</PackageId>
2929
<Title>Trimble Modus</Title>
30-
<Version>1.4.0.1</Version>
30+
<Version>1.4.0.2</Version>
3131
<Authors>Trimble Inc</Authors>
3232
<Company>Trimble Inc</Company>
3333
<Product>Trimble.Modus.Components</Product>
@@ -202,6 +202,9 @@
202202
<MauiXaml Update="Styles\Colors.xaml">
203203
<Generator></Generator>
204204
</MauiXaml>
205+
<MauiXaml Update="Styles\ConvertersDictionary.xaml">
206+
<Generator>MSBuild:Compile</Generator>
207+
</MauiXaml>
205208
<MauiXaml Update="Styles\DarkThemeStyling.xaml">
206209
<Generator>MSBuild:Compile</Generator>
207210
</MauiXaml>

0 commit comments

Comments
 (0)