瀏覽代碼

Merge pull request #801 from PixiEditor/fixes/18.03

Null check in TryConvert
Krzysztof Krysiński 9 月之前
父節點
當前提交
dc2b68dfb0
共有 1 個文件被更改,包括 8 次插入3 次删除
  1. 8 3
      src/PixiEditor.ChangeableDocument/Changes/NodeGraph/ConversionTable.cs

+ 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))),
                 ]
             }
         };
 
-    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)
         {
             try