Skip to content

Portable Tool for an Ideal Windows Setup

fix profile and wallpaper image loading failures when registry paths are invalid deb v5.3.7

Greedeks289f69568de4
diff --git a/.Source/GTweak/Properties/AssemblyInfo.cs b/.Source/GTweak/Properties/AssemblyInfo.cs
index 8e987afa..a1cd9c51 100644
--- a/.Source/GTweak/Properties/AssemblyInfo.cs
+++ b/.Source/GTweak/Properties/AssemblyInfo.cs
@@ -5,11 +5,11 @@ using System.Windows;
[assembly: AssemblyTitle("GTweak")]
[assembly: AssemblyDescription("Portable Tool for an Ideal Windows Setup")]
[assembly: AssemblyProduct("GTweak")]
-[assembly: AssemblyCopyright("© 2024-2025 Greedeks")]
+[assembly: AssemblyCopyright("� 2024-2025 Greedeks")]
[assembly: AssemblyTrademark("Greedeks")]
-[assembly: AssemblyInformationalVersion("Build: 5.3.6")]
-[assembly: AssemblyVersion("5.3.22.201")]
-[assembly: AssemblyFileVersion("5.3.22.201")]
+[assembly: AssemblyInformationalVersion("Build: 5.3.7")]
+[assembly: AssemblyVersion("5.3.29.241")]
+[assembly: AssemblyFileVersion("5.3.29.241")]
[assembly: ComVisible(false)]
diff --git a/.Source/GTweak/Properties/AssemblyInfo.tt b/.Source/GTweak/Properties/AssemblyInfo.tt
index 4ccc5d6e..92972572 100644
--- a/.Source/GTweak/Properties/AssemblyInfo.tt
+++ b/.Source/GTweak/Properties/AssemblyInfo.tt
@@ -22,7 +22,7 @@ using System.Windows;
[assembly: AssemblyMetadata("RepositoryType", "git")]
<#+
- private const string majorVersion = "Build: 5.3.6";
+ private const string majorVersion = "Build: 5.3.7";
private string GenerateVersion()
{
diff --git a/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs b/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs
index 4277d5eb..9f6ae491 100644
--- a/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs
+++ b/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs
@@ -71,8 +71,27 @@ namespace GTweak.Utilities.Configuration
internal ImageSource GetProfileImage()
{
- string imageSrc = RegistryHelp.GetValue($@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AccountPicture\Users\{WindowsIdentity.GetCurrent().User?.Value}", "Image1080", string.Empty);
- return !string.IsNullOrWhiteSpace(imageSrc) ? new BitmapImage(new Uri(imageSrc)) : Application.Current.Resources["Icon_ProfileAvatar"] as ImageSource;
+ try
+ {
+ string avatarPath = RegistryHelp.GetValue($@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AccountPicture\Users\{WindowsIdentity.GetCurrent().User?.Value}", "Image1080", string.Empty);
+
+ if (!string.IsNullOrWhiteSpace(avatarPath) && File.Exists(avatarPath) && new FileInfo(avatarPath).Length != 0)
+ {
+ BitmapImage bmp = new BitmapImage();
+ bmp.BeginInit();
+ bmp.UriSource = new Uri(avatarPath, UriKind.Absolute);
+ bmp.CacheOption = BitmapCacheOption.OnLoad;
+ bmp.EndInit();
+ bmp.Freeze();
+ return bmp;
+ }
+ }
+ catch (Exception ex)
+ {
+ ErrorLogging.LogDebug(ex);
+ }
+
+ return (ImageSource)Application.Current.Resources["Icon_ProfileAvatar"];
}
internal string GetProfileName()
@@ -147,15 +166,32 @@ namespace GTweak.Utilities.Configuration
private void GetWallpaperImage()
{
- BitmapImage bmp = new BitmapImage();
- bmp.BeginInit();
- bmp.UriSource = new Uri(RegistryHelp.GetValue(@"HKEY_CURRENT_USER\Control Panel\Desktop", "WallPaper", string.Empty), UriKind.Absolute);
- bmp.DecodePixelWidth = 100;
- bmp.CacheOption = BitmapCacheOption.OnLoad;
- bmp.CreateOptions = BitmapCreateOptions.IgnoreColorProfile;
- bmp.EndInit();
- bmp.Freeze();
- Wallpaper = bmp;
+ try
+ {
+ string wallpaperPath = RegistryHelp.GetValue(@"HKEY_CURRENT_USER\Control Panel\Desktop", "WallPaper", string.Empty);
+
+ if (!string.IsNullOrWhiteSpace(wallpaperPath) && File.Exists(wallpaperPath))
+ {
+ BitmapImage bmp = new BitmapImage();
+ bmp.BeginInit();
+ bmp.UriSource = new Uri(wallpaperPath, UriKind.Absolute);
+ bmp.DecodePixelWidth = 100;
+ bmp.CacheOption = BitmapCacheOption.OnLoad;
+ bmp.CreateOptions = BitmapCreateOptions.IgnoreColorProfile;
+ bmp.EndInit();
+ bmp.Freeze();
+ Wallpaper = bmp;
+ }
+ else
+ {
+ Wallpaper = null;
+ }
+ }
+ catch (Exception ex)
+ {
+ ErrorLogging.LogDebug(ex);
+ Wallpaper = null;
+ }
}
internal void GetOperatingSystemInfo()
diff --git a/.Source/GTweak/View/DataSystemView.xaml b/.Source/GTweak/View/DataSystemView.xaml
index 492bd52a..baa990c0 100644
--- a/.Source/GTweak/View/DataSystemView.xaml
+++ b/.Source/GTweak/View/DataSystemView.xaml
@@ -60,7 +60,7 @@
<StackPanel Orientation="Horizontal">
<Border Width="70" Height="70" HorizontalAlignment="Right">
<Border.Background>
- <ImageBrush ImageSource="{Binding DisplayWallpaper, Mode=OneWay}" Stretch="UniformToFill"/>
+ <ImageBrush ImageSource="{Binding DisplayWallpaper, TargetNullValue={StaticResource Icon_LogoWin}, Mode=OneWay}" Stretch="UniformToFill"/>
</Border.Background>
<Border.OpacityMask>
<ImageBrush ImageSource="{StaticResource Icon_LogoWin}" Stretch="Uniform"/>
diff --git a/.Source/GTweak/Windows/LoadingWindow.xaml b/.Source/GTweak/Windows/LoadingWindow.xaml
index 8577d485..7e6f56e7 100644
--- a/.Source/GTweak/Windows/LoadingWindow.xaml
+++ b/.Source/GTweak/Windows/LoadingWindow.xaml
@@ -1,4 +1,4 @@
-<ui:FluentWindow x:Class="GTweak.Windows.LoadingWindow"
+<ui:FluentWindow x:Class="GTweak.Windows.LoadingWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
@@ -23,7 +23,7 @@
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
- <Image Source="{Binding DisplayProfileAvatar}" Stretch="UniformToFill">
+ <Image Source="{Binding DisplayProfileAvatar, TargetNullValue={StaticResource Icon_ProfileAvatar}}" Stretch="UniformToFill">
<Image.OpacityMask>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
<GradientStop Offset="0" Color="#FFFFFFFF"/>
diff --git a/.Source/GTweak/Windows/MainWindow.xaml b/.Source/GTweak/Windows/MainWindow.xaml
index 054453a1..ec175e8c 100644
--- a/.Source/GTweak/Windows/MainWindow.xaml
+++ b/.Source/GTweak/Windows/MainWindow.xaml
@@ -52,7 +52,7 @@
<DropShadowEffect BlurRadius="20" ShadowDepth="0" Opacity="0.7" Color="{StaticResource Color_Shadow}" />
</Border.Effect>
<Border.Background>
- <ImageBrush ImageSource="{Binding DisplayProfileAvatar, Mode=OneWay}" Stretch="Uniform"/>
+ <ImageBrush ImageSource="{Binding DisplayProfileAvatar, TargetNullValue={StaticResource Icon_ProfileAvatar}, Mode=OneWay}" Stretch="Uniform"/>
</Border.Background>
</Border>
</Border>