Browse Source

Merge pull request #801 from PixiEditor/fixes/18.03

Null check in TryConvert
Krzysztof Krysiński 5 months ago
parent
commit
dc2b68dfb0

+ 8 - 3
src/PixiEditor.ChangeableDocument/Changes/NodeGraph/ConversionTable.cs

@@ -42,15 +42,20 @@ public static class ConversionTable
                 ]
                 ]
             },
             },
             {
             {
-                typeof(Color),
-                [
+                typeof(Color), [
                     (typeof(Paintable), new TypeConverter<Color, Paintable>(c => new ColorPaintable(c))),
                     (typeof(Paintable), new TypeConverter<Color, Paintable>(c => new ColorPaintable(c))),
                 ]
                 ]
             }
             }
         };
         };
 
 
-    public static bool TryConvert(object arg, Type targetType, out object result)
+    public static bool TryConvert(object? arg, Type targetType, out object result)
     {
     {
+        if (arg is null)
+        {
+            result = null;
+            return false;
+        }
+
         if (arg is Delegate func)
         if (arg is Delegate func)
         {
         {
             try
             try