Open Joezeo opened 1 month ago
This is a variant of https://github.com/godot-rust/gdext/issues/338.
The TLDR is that Rust cannot borrow-check through FFI calls, so:
on_input
binds the object mutably on the emit side_on_state_transition
binds the object mutably in the signal callbackThis causes a double runtime borrow.
We should see if #[func(virtual)]
and/or signals can use "re-borrowing", i.e. the base_mut()
pattern, to work around it. This needs some design though.
Here is the sample code
State's
on_input
function was overridden in GDScript, and emitted the signalstate_transition
there, causing the panic.I tried to mark the _on_state_transition function with gd_self. There was no panic if it was an empty function, but it still panicked when I tried to call some functions on Gd\<Self>.