From f019163083852d8e6df007fdba93d0689484a944 Mon Sep 17 00:00:00 2001 From: Ani <115020168+drawbyperpetual@users.noreply.github.com> Date: Sun, 16 Jun 2024 17:58:25 +0200 Subject: [PATCH] [Settings]Ensure PTRun plugin icon paths are well formed / add unhandled exception handler (#33374) * Fixed production crash with bad icon paths in Launcher plugins * Bumped MSBuildCacheCacheUniverse --- src/settings-ui/Settings.UI/SettingsXAML/App.xaml.cs | 11 +++++++++-- .../ViewModels/PowerLauncherPluginViewModel.cs | 7 +++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/settings-ui/Settings.UI/SettingsXAML/App.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/App.xaml.cs index 96c05c0223..263e0466f6 100644 --- a/src/settings-ui/Settings.UI/SettingsXAML/App.xaml.cs +++ b/src/settings-ui/Settings.UI/SettingsXAML/App.xaml.cs @@ -76,9 +76,16 @@ namespace Microsoft.PowerToys.Settings.UI /// public App() { - Logger.InitializeLogger("\\Settings\\Logs"); + Logger.InitializeLogger(@"\Settings\Logs"); - this.InitializeComponent(); + InitializeComponent(); + + UnhandledException += App_UnhandledException; + } + + private void App_UnhandledException(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e) + { + Logger.LogError("Unhandled exception", e.Exception); } public static void OpenSettingsWindow(Type type = null, bool ensurePageIsSelected = false) diff --git a/src/settings-ui/Settings.UI/ViewModels/PowerLauncherPluginViewModel.cs b/src/settings-ui/Settings.UI/ViewModels/PowerLauncherPluginViewModel.cs index c337aa1e5c..c350222c35 100644 --- a/src/settings-ui/Settings.UI/ViewModels/PowerLauncherPluginViewModel.cs +++ b/src/settings-ui/Settings.UI/ViewModels/PowerLauncherPluginViewModel.cs @@ -179,10 +179,9 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels return $"{Name}. {Description}"; } - public string IconPath - { - get => isDark() ? settings.IconPathDark : settings.IconPathLight; - } +#nullable enable + public Uri? IconPath => Uri.TryCreate(isDark() ? settings.IconPathDark : settings.IconPathLight, UriKind.Absolute, out var uri) ? uri : null; +#nullable restore public event PropertyChangedEventHandler PropertyChanged;