diff --git a/godot-core/src/builtin/meta/signature.rs b/godot-core/src/builtin/meta/signature.rs index 415f8f1d4..cce236dfe 100644 --- a/godot-core/src/builtin/meta/signature.rs +++ b/godot-core/src/builtin/meta/signature.rs @@ -162,8 +162,9 @@ macro_rules! impl_signature_for_tuple { unsafe { <$R as sys::GodotFuncMarshal>::try_write_sys(&ret_val, ret) } .unwrap_or_else(|e| return_error::<$R>(method_name, &e)); - // FIXME is inc_ref needed here? - // std::mem::forget(ret_val); + //Note: we want to prevent the destructor from being run, since we pass ownership to the caller. + //https://github.com/godot-rust/gdext/pull/165 + std::mem::forget(ret_val); } } }; diff --git a/itest/godot/InheritTests.gd b/itest/godot/InheritTests.gd new file mode 100644 index 000000000..31efde916 --- /dev/null +++ b/itest/godot/InheritTests.gd @@ -0,0 +1,27 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at https://mozilla.org/MPL/2.0/. + +extends ArrayTest + +var test_suite: TestSuite = TestSuite.new() + +# In order to reproduce the bahevaior discovered in https://github.com/godot-rust/gdext/issues/138 +# we must inherit a Godot Node. Because of this we can't just inherit TesSuite like the rest of the tests. +func assert_that(what: bool, message: String = "") -> bool: + return test_suite.assert_that(what, message) + +func assert_eq(left, right, message: String = "") -> bool: + return test_suite.assert_eq(left, right, message) + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass + +func test_vector_array_return_from_user_func(): + var array: Array = return_typed_array(2) + assert_eq(array, [1,2]) + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass diff --git a/itest/godot/TestRunner.gd b/itest/godot/TestRunner.gd index 98376e561..45008f88e 100644 --- a/itest/godot/TestRunner.gd +++ b/itest/godot/TestRunner.gd @@ -10,6 +10,7 @@ func _ready(): var gdscript_suites: Array = [ preload("res://ManualFfiTests.gd").new(), preload("res://gen/GenFfiTests.gd").new(), + preload("res://InheritTests.gd").new() ] var gdscript_tests: Array = []