2
0
Эх сурвалжийг харах

Merge pull request #89756 from zaevi/dotnet/fix_null_array

C#: Fix errors when creating `Variant` from null array
Rémi Verschelde 1 жил өмнө
parent
commit
3895639f72

+ 18 - 3
modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.cs

@@ -235,13 +235,28 @@ namespace Godot.NativeInterop
         }
         }
 
 
         public static godot_variant CreateFromSystemArrayOfStringName(Span<StringName> from)
         public static godot_variant CreateFromSystemArrayOfStringName(Span<StringName> from)
-            => CreateFromArray(new Collections.Array(from));
+        {
+            if (from == null)
+                return default;
+            using var fromGodot = new Collections.Array(from);
+            return CreateFromArray((godot_array)fromGodot.NativeValue);
+        }
 
 
         public static godot_variant CreateFromSystemArrayOfNodePath(Span<NodePath> from)
         public static godot_variant CreateFromSystemArrayOfNodePath(Span<NodePath> from)
-            => CreateFromArray(new Collections.Array(from));
+        {
+            if (from == null)
+                return default;
+            using var fromGodot = new Collections.Array(from);
+            return CreateFromArray((godot_array)fromGodot.NativeValue);
+        }
 
 
         public static godot_variant CreateFromSystemArrayOfRid(Span<Rid> from)
         public static godot_variant CreateFromSystemArrayOfRid(Span<Rid> from)
-            => CreateFromArray(new Collections.Array(from));
+        {
+            if (from == null)
+                return default;
+            using var fromGodot = new Collections.Array(from);
+            return CreateFromArray((godot_array)fromGodot.NativeValue);
+        }
 
 
         public static godot_variant CreateFromSystemArrayOfGodotObject(GodotObject[]? from)
         public static godot_variant CreateFromSystemArrayOfGodotObject(GodotObject[]? from)
         {
         {