From 61717dcd50020dd23a04276b81ac3f47d687d7aa Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Thu, 12 Jun 2025 18:51:03 +0800 Subject: [PATCH] Ensure SetImageAsync exceptions are handled --- Flow.Launcher/UACDialog.xaml.cs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Flow.Launcher/UACDialog.xaml.cs b/Flow.Launcher/UACDialog.xaml.cs index aa87125ad..040f10328 100644 --- a/Flow.Launcher/UACDialog.xaml.cs +++ b/Flow.Launcher/UACDialog.xaml.cs @@ -62,13 +62,22 @@ namespace Flow.Launcher private async Task SetImageAsync(string imagePath) { - if (string.IsNullOrEmpty(imagePath) || !File.Exists(imagePath)) + try { - Img.Visibility = Visibility.Collapsed; - return; + if (string.IsNullOrEmpty(imagePath) || !File.Exists(imagePath)) + { + Img.Visibility = Visibility.Collapsed; + return; + } + var imageSource = await App.API.LoadImageAsync(imagePath); + Img.Source = imageSource; + Img.Visibility = Visibility.Visible; + } + catch (Exception ex) + { + App.API.LogException(ClassName, $"Failed to load UAC dialog image: {imagePath}", ex); + Img.Visibility = Visibility.Collapsed; } - var imageSource = await App.API.LoadImageAsync(imagePath); - Img.Source = imageSource; } private void KeyEsc_OnPress(object sender, ExecutedRoutedEventArgs e)