mirror of
https://github.com/godotengine/godot.git
synced 2024-12-09 10:09:20 +08:00
Fix: Func with typed args error when arg is null
This commit is contained in:
parent
37589edf17
commit
30d4d3fa5e
@ -105,9 +105,10 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
Object *obj = p_variant.get_validated_object();
|
||||
bool was_freed = false;
|
||||
Object *obj = p_variant.get_validated_object_with_check(was_freed);
|
||||
if (!obj) {
|
||||
return false;
|
||||
return !was_freed;
|
||||
}
|
||||
|
||||
if (!ClassDB::is_parent_class(obj->get_class_name(), native_type)) {
|
||||
@ -124,9 +125,10 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
Object *obj = p_variant.get_validated_object();
|
||||
bool was_freed = false;
|
||||
Object *obj = p_variant.get_validated_object_with_check(was_freed);
|
||||
if (!obj) {
|
||||
return false;
|
||||
return !was_freed;
|
||||
}
|
||||
|
||||
Ref<Script> base = obj && obj->get_script_instance() ? obj->get_script_instance()->get_script() : nullptr;
|
||||
|
@ -0,0 +1,27 @@
|
||||
# https://github.com/godotengine/godot/issues/72967
|
||||
|
||||
class CustomNode:
|
||||
extends Node
|
||||
|
||||
static func test_custom_node(n: CustomNode):
|
||||
if not n:
|
||||
print("null node")
|
||||
|
||||
func test():
|
||||
test_typed_argument_is_null()
|
||||
|
||||
func get_custom_node() -> CustomNode:
|
||||
return null
|
||||
|
||||
func test_typed_argument_is_null():
|
||||
var node: Node = Node.new()
|
||||
print_node_name(node.get_parent())
|
||||
node.free()
|
||||
test_custom_node()
|
||||
|
||||
func test_custom_node():
|
||||
CustomNode.test_custom_node(get_custom_node())
|
||||
|
||||
func print_node_name(n: Node):
|
||||
if not n:
|
||||
print("null node")
|
@ -0,0 +1,3 @@
|
||||
GDTEST_OK
|
||||
null node
|
||||
null node
|
Loading…
Reference in New Issue
Block a user