From 8176c01a9193781c5a90f63aaf205e6b3aebd5ec Mon Sep 17 00:00:00 2001 From: Jan Haller Date: Sun, 24 Nov 2024 19:14:27 +0100 Subject: [PATCH] Allow passing DynGd to Godot APIs --- godot-core/src/meta/args/object_arg.rs | 1 - itest/rust/src/object_tests/dyn_gd_test.rs | 12 ++++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/godot-core/src/meta/args/object_arg.rs b/godot-core/src/meta/args/object_arg.rs index 304bd76db..741605a1e 100644 --- a/godot-core/src/meta/args/object_arg.rs +++ b/godot-core/src/meta/args/object_arg.rs @@ -81,7 +81,6 @@ where } } */ - impl AsObjectArg for &Gd where T: GodotClass + Bounds, diff --git a/itest/rust/src/object_tests/dyn_gd_test.rs b/itest/rust/src/object_tests/dyn_gd_test.rs index 34ee1c728..b88556703 100644 --- a/itest/rust/src/object_tests/dyn_gd_test.rs +++ b/itest/rust/src/object_tests/dyn_gd_test.rs @@ -153,6 +153,18 @@ fn dyn_gd_downgrade() { assert_eq!(gd.instance_id(), dyn_id); } +#[itest] +fn dyn_gd_pass_to_godot_api() { + let child = foreign::NodeHealth::new_alloc().into_dyn(); + + let mut parent = Node::new_alloc(); + parent.add_child(&child); + + assert_eq!(child.get_parent().as_ref(), Some(&parent)); + + parent.free(); +} + // ---------------------------------------------------------------------------------------------------------------------------------------------- // Example symbols