Skip to content

Commit 3321bca

Browse files
committed
-Attempts to fix godot-rust#138. Revert of ac02be1.
1 parent 55c4d3a commit 3321bca

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ macro_rules! impl_signature_for_tuple {
163163
.unwrap_or_else(|e| return_error::<$R>(method_name, &e));
164164

165165
// FIXME is inc_ref needed here?
166-
// std::mem::forget(ret_val);
166+
std::mem::forget(ret_val);
167167
}
168168
}
169169
};

godot-core/src/macros.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ macro_rules! gdext_ptrcall {
414414

415415
<$($RetTy)+ as sys::GodotFfi>::write_sys(&ret_val, $ret);
416416
// FIXME is inc_ref needed here?
417-
// #[allow(clippy::forget_copy)]
418-
// std::mem::forget(ret_val);
417+
#[allow(clippy::forget_copy)]
418+
std::mem::forget(ret_val);
419419
};
420420
}

godot-core/src/obj/base.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ impl<T: GodotClass> Base<T> {
4040
assert!(!base_ptr.is_null(), "instance base is null pointer");
4141

4242
// Initialize only as weak pointer (don't increment reference count)
43-
let obj = Gd::from_obj_sys_weak(base_ptr);
43+
44+
let obj = Gd::from_obj_sys(base_ptr);
4445

4546
// This obj does not contribute to the strong count, otherwise we create a reference cycle:
4647
// 1. RefCounted (dropped in GDScript)

godot-core/src/obj/gd.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,17 @@ where
8686
where
8787
T: cap::GodotInit,
8888
{
89-
unsafe {
89+
let result = unsafe {
9090
let object_ptr = callbacks::create::<T>(ptr::null_mut());
9191
Gd::from_obj_sys(object_ptr)
92+
};
93+
94+
95+
T::Mem::maybe_init_ref(&result);
96+
result
9297
}
93-
}
98+
99+
94100

95101
/// Creates a `Gd<T>` using a function that constructs a `T` from a provided base.
96102
///

0 commit comments

Comments
 (0)