Skip to content

Commit def7a0f

Browse files
bors[bot]lilizoey
andauthored
Merge #250
250: fix callable crashing when from_sys_init_default is used r=Bromeon a=lilizoey callable needed to override `from_sys_init_default` in the usual way. closes #248 Co-authored-by: Lili Zoey <[email protected]>
2 parents bab1070 + 7d68dc2 commit def7a0f

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

godot-core/src/builtin/callable.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,12 @@ impl_builtin_traits! {
180180
// beyond what is done in `from_opaque` and `drop`. So using `*mut Opaque` is safe.
181181
unsafe impl GodotFfi for Callable {
182182
ffi_methods! { type sys::GDExtensionTypePtr = *mut Opaque; .. }
183+
184+
unsafe fn from_sys_init_default(init_fn: impl FnOnce(sys::GDExtensionTypePtr)) -> Self {
185+
let mut result = Self::default();
186+
init_fn(result.sys_mut());
187+
result
188+
}
183189
}
184190

185191
impl std::fmt::Debug for Callable {

itest/rust/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ fn collect_inputs() -> Vec<Input> {
6262
push!(inputs; Vector4, Vector4, Vector4(-18.5, 24.75, -1.25, 777.875), Vector4::new(-18.5, 24.75, -1.25, 777.875));
6363
push!(inputs; Vector2i, Vector2i, Vector2i(-2147483648, 2147483647), Vector2i::new(-2147483648, 2147483647));
6464
push!(inputs; Vector3i, Vector3i, Vector3i(-1, -2147483648, 2147483647), Vector3i::new(-1, -2147483648, 2147483647));
65+
push!(inputs; Callable, Callable, Callable(), Callable::default());
6566

6667
// Data structures
6768
// TODO enable below, when GDScript has typed array literals, or find a hack with eval/lambdas

0 commit comments

Comments
 (0)