Skip to content

Commit 8b7b786

Browse files
committed
-Fixes #165.
1 parent 55c4d3a commit 8b7b786

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

godot-core/src/builtin/meta/signature.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,9 @@ macro_rules! impl_signature_for_tuple {
162162
unsafe { <$R as sys::GodotFuncMarshal>::try_write_sys(&ret_val, ret) }
163163
.unwrap_or_else(|e| return_error::<$R>(method_name, &e));
164164

165-
// FIXME is inc_ref needed here?
166-
// std::mem::forget(ret_val);
165+
//Note: we want to prevent the destructor from being run, since we pass ownership to the caller.
166+
//https://github.com/godot-rust/gdext/pull/165
167+
std::mem::forget(ret_val);
167168
}
168169
}
169170
};

itest/godot/InheritTests.gd

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
5+
extends ArrayTest
6+
7+
var test_suite: TestSuite = TestSuite.new()
8+
9+
# In order to reproduce the bahevaior discovered in https://github.com/godot-rust/gdext/issues/138
10+
# we must inherit a Godot Node. Because of this we can't just inherit TesSuite like the rest of the tests.
11+
func assert_that(what: bool, message: String = "") -> bool:
12+
return test_suite.assert_that(what, message)
13+
14+
func assert_eq(left, right, message: String = "") -> bool:
15+
return test_suite.assert_eq(left, right, message)
16+
17+
# Called when the node enters the scene tree for the first time.
18+
func _ready():
19+
pass
20+
21+
func test_vector_array_return_from_user_func():
22+
var array: Array = return_typed_array(2)
23+
assert_eq(array, [1,2])
24+
25+
# Called every frame. 'delta' is the elapsed time since the previous frame.
26+
func _process(delta):
27+
pass

itest/godot/TestRunner.gd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ func _ready():
1010
var gdscript_suites: Array = [
1111
preload("res://ManualFfiTests.gd").new(),
1212
preload("res://gen/GenFfiTests.gd").new(),
13+
preload("res://InheritTests.gd").new()
1314
]
1415

1516
var gdscript_tests: Array = []

0 commit comments

Comments
 (0)