From: shivamv Date: Fri, 30 Sep 2022 11:21:59 +0000 (+0530) Subject: Fixing SVACE handle leaks in tray and null deref check in Apps X-Git-Tag: accepted/tizen/unified/20221004.073935^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8e4d9c1e16f3391330b8db0f40a7b4bf1d7543e5;p=profile%2Fiot%2Fapps%2Fdotnet%2Ftray.git Fixing SVACE handle leaks in tray and null deref check in Apps Change-Id: I089a2c99aecb4b5e8d350489b3a04960fc9ff844 Signed-off-by: shivamv --- diff --git a/Apps/Models/AppInfoModel.cs b/Apps/Models/AppInfoModel.cs index e7a301a..fa487df 100755 --- a/Apps/Models/AppInfoModel.cs +++ b/Apps/Models/AppInfoModel.cs @@ -35,16 +35,16 @@ namespace Apps.Models set => SetProperty(ref iconBackground, value); } - private void SetDefaultBackground() + private ImageVisual GetDefaultImageVisual() { ImageVisual imageVisual = new ImageVisual() { URL = Resources.GetImagePath() + "default_gradient.png", }; - IconBackground = imageVisual.OutputVisualMap; + return imageVisual; } - private void SetGradientBackground(PropertyArray stopColor) + private GradientVisual GetGradientVisual(PropertyArray stopColor) { GradientVisual gradientVisual = new GradientVisual() { @@ -53,7 +53,7 @@ namespace Apps.Models StopColor = stopColor, SpreadMethod = GradientVisualSpreadMethodType.Pad, }; - IconBackground = gradientVisual.OutputVisualMap; + return gradientVisual; } private PropertyArray GetGradientStopColors(Palette palette) @@ -124,12 +124,12 @@ namespace Apps.Models if (stopColor.Count() < 2) { Tizen.Log.Info(Resources.LogTag, "Palette or palatte values not valid, adding default gradient"); - SetDefaultBackground(); + IconBackground = GetDefaultImageVisual().OutputVisualMap; } else { - Tizen.Log.Info(Resources.LogTag, "setting palette color"); - SetGradientBackground(stopColor); + Tizen.Log.Info(Resources.LogTag, "setting palette color"); + IconBackground = GetGradientVisual(stopColor).OutputVisualMap; } } } diff --git a/Apps/ViewModels/AppInfoViewModel.cs b/Apps/ViewModels/AppInfoViewModel.cs index 797cac0..0958e09 100755 --- a/Apps/ViewModels/AppInfoViewModel.cs +++ b/Apps/ViewModels/AppInfoViewModel.cs @@ -16,9 +16,13 @@ namespace Apps.ViewModels public void CreateData(IEnumerable list) { Clear(); + if(list == null) + { + return; + } foreach (ApplicationInfo appInfo in list) { - if (string.IsNullOrEmpty(appInfo.IconPath)) + if (appInfo == null || string.IsNullOrEmpty(appInfo.IconPath)) { continue; } diff --git a/TrayApplication/Models/AppInfoModel.cs b/TrayApplication/Models/AppInfoModel.cs index 13d917c..4d57ab9 100755 --- a/TrayApplication/Models/AppInfoModel.cs +++ b/TrayApplication/Models/AppInfoModel.cs @@ -55,6 +55,7 @@ namespace TrayApplication.Models URL = Resources.GetImagePath() + "default_gradient.png", }; IconBackground = imageVisual.OutputVisualMap; + imageVisual.Dispose(); } private void SetGradientBackground(PropertyArray stopColor) @@ -67,6 +68,7 @@ namespace TrayApplication.Models SpreadMethod = GradientVisualSpreadMethodType.Pad, }; IconBackground = gradientVisual.OutputVisualMap; + gradientVisual.Dispose(); } private PropertyArray GetGradientStopColors(Palette palette) diff --git a/packaging/org.tizen.Apps-1.0.0.tpk b/packaging/org.tizen.Apps-1.0.0.tpk index 14a309b..58bcbd4 100755 Binary files a/packaging/org.tizen.Apps-1.0.0.tpk and b/packaging/org.tizen.Apps-1.0.0.tpk differ diff --git a/packaging/org.tizen.TrayApplication-1.0.0.tpk b/packaging/org.tizen.TrayApplication-1.0.0.tpk index 7282e54..9effc77 100755 Binary files a/packaging/org.tizen.TrayApplication-1.0.0.tpk and b/packaging/org.tizen.TrayApplication-1.0.0.tpk differ