Skip to content

Commit

Permalink
-Fixes godot-rust#165.
Browse files Browse the repository at this point in the history
  • Loading branch information
thebigG committed Mar 22, 2023
1 parent 55c4d3a commit 8b7b786
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
5 changes: 3 additions & 2 deletions godot-core/src/builtin/meta/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
};
Expand Down
27 changes: 27 additions & 0 deletions itest/godot/InheritTests.gd
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions itest/godot/TestRunner.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down

0 comments on commit 8b7b786

Please sign in to comment.