Skip to content

Commit

Permalink
Merge pull request godotengine#76483 from vnen/gdscript-dont-fail-ret…
Browse files Browse the repository at this point in the history
…urning-freed-object

GDScript: Don't fail when freed object is return
  • Loading branch information
akien-mga committed Apr 27, 2023
2 parents 58439ac + abbdf80 commit 352ebe9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
4 changes: 0 additions & 4 deletions modules/gdscript/gdscript_vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1651,10 +1651,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
bool was_freed = false;
Object *obj = ret->get_validated_object_with_check(was_freed);

if (was_freed) {
err_text = "Got a freed object as a result of the call.";
OPCODE_BREAK;
}
if (obj && obj->is_class_ptr(GDScriptFunctionState::get_class_ptr_static())) {
err_text = R"(Trying to call an async function without "await".)";
OPCODE_BREAK;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# https://github.com/godotengine/godot/issues/68184

var node: Node:
get:
return node
set(n):
node = n


func test():
node = Node.new()
node.free()

if !is_instance_valid(node):
print("It is freed")
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
GDTEST_OK
It is freed

0 comments on commit 352ebe9

Please sign in to comment.