diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-07-03 15:22:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-03 15:22:25 +0200 |
commit | 488576ade9fb59fbec7b24514b655c1579403c57 (patch) | |
tree | d6d8323298bdc61a1b6e776a270f95fba2f54c35 /modules | |
parent | 772f693e5b8b5912d422e8effb8d6a72260edcfc (diff) | |
parent | d2461bad637c65fa41150725eeae4bb197662ea3 (diff) |
Merge pull request #40078 from endlesstravel/fix-print-null-in-array-3
fix crash when pass null in print array in GD.print
Diffstat (limited to 'modules')
-rw-r--r-- | modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs | 10 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono_marshal.cpp | 4 |
2 files changed, 9 insertions, 5 deletions
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs index 9384da0e48..e050d1fdd1 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs @@ -84,7 +84,7 @@ namespace Godot public static void Print(params object[] what) { - godot_icall_GD_print(Array.ConvertAll(what, x => x?.ToString())); + godot_icall_GD_print(Array.ConvertAll(what ?? new object[]{"null"}, x => x != null ? x.ToString() : "null")); } public static void PrintStack() @@ -94,22 +94,22 @@ namespace Godot public static void PrintErr(params object[] what) { - godot_icall_GD_printerr(Array.ConvertAll(what, x => x?.ToString())); + godot_icall_GD_printerr(Array.ConvertAll(what ?? new object[]{"null"}, x => x != null ? x.ToString() : "null")); } public static void PrintRaw(params object[] what) { - godot_icall_GD_printraw(Array.ConvertAll(what, x => x?.ToString())); + godot_icall_GD_printraw(Array.ConvertAll(what ?? new object[]{"null"}, x => x != null ? x.ToString() : "null")); } public static void PrintS(params object[] what) { - godot_icall_GD_prints(Array.ConvertAll(what, x => x?.ToString())); + godot_icall_GD_prints(Array.ConvertAll(what ?? new object[]{"null"}, x => x != null ? x.ToString() : "null")); } public static void PrintT(params object[] what) { - godot_icall_GD_printt(Array.ConvertAll(what, x => x?.ToString())); + godot_icall_GD_printt(Array.ConvertAll(what ?? new object[]{"null"}, x => x != null ? x.ToString() : "null")); } public static float Randf() diff --git a/modules/mono/mono_gd/gd_mono_marshal.cpp b/modules/mono/mono_gd/gd_mono_marshal.cpp index 158742846b..92734a0792 100644 --- a/modules/mono/mono_gd/gd_mono_marshal.cpp +++ b/modules/mono/mono_gd/gd_mono_marshal.cpp @@ -1035,6 +1035,10 @@ Variant mono_object_to_variant_no_err(MonoObject *p_obj, const ManagedType &p_ty } String mono_object_to_variant_string(MonoObject *p_obj, MonoException **r_exc) { + if (p_obj == nullptr) { + return String("null"); + } + ManagedType type = ManagedType::from_class(mono_object_get_class(p_obj)); Variant var = GDMonoMarshal::mono_object_to_variant_no_err(p_obj, type); |