Skip to content

Commit 9480979

Browse files
committed
fix warning for null thumbnail after deleting project from list
1 parent 812ac2a commit 9480979

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

UnityLauncherPro/Converters/ThumbnailConverter.cs

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Globalization;
33
using System.IO;
4+
using System.Windows;
45
using System.Windows.Data;
56
using System.Windows.Media.Imaging;
67

@@ -10,6 +11,12 @@ public class ThumbnailConverter : IValueConverter
1011
{
1112
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
1213
{
14+
// Return UnsetValue if no project is selected
15+
if (value == null)
16+
{
17+
return DependencyProperty.UnsetValue;
18+
}
19+
1320
if (value is Project project)
1421
{
1522
if (!string.IsNullOrEmpty(project.Path))
@@ -20,6 +27,13 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
2027
{
2128
try
2229
{
30+
// Check if this is for Width/Height parameter
31+
if (parameter != null && (parameter.ToString() == "Width" || parameter.ToString() == "Height"))
32+
{
33+
return 64.0; // Return default dimension
34+
}
35+
36+
// For Source binding, load the bitmap
2337
var bitmap = new BitmapImage();
2438
bitmap.BeginInit();
2539
bitmap.CacheOption = BitmapCacheOption.OnLoad;
@@ -40,14 +54,25 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
4054
}
4155
catch
4256
{
43-
// Ignore and fall back to null
57+
// Ignore and fall back to UnsetValue for Source, or 64.0 for dimensions
58+
if (parameter != null && (parameter.ToString() == "Width" || parameter.ToString() == "Height"))
59+
{
60+
return 64.0;
61+
}
62+
return DependencyProperty.UnsetValue;
4463
}
4564
}
4665
}
47-
return null;
66+
67+
// Project path doesn't exist or no thumbnail found
68+
if (parameter != null && (parameter.ToString() == "Width" || parameter.ToString() == "Height"))
69+
{
70+
return 64.0; // Return default dimension
71+
}
72+
return DependencyProperty.UnsetValue;
4873
}
4974

50-
return null;
75+
return DependencyProperty.UnsetValue;
5176
}
5277

5378
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)

0 commit comments

Comments
 (0)