mirror of
https://github.com/godotengine/godot.git
synced 2024-12-15 10:12:40 +08:00
Merge pull request #40078 from endlesstravel/fix-print-null-in-array-3
fix crash when pass null in print array in GD.print
This commit is contained in:
commit
488576ade9
@ -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()
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user