gdext
gdext copied to clipboard
Crash when using can_drop_data
I have the game crashing in almost any scenario using drop_data. Even with something as simple as this:
fn get_drag_data(&mut self, _at_position: Vector2) -> Variant {
let drag_data = "test".to_variant();
return drag_data;
}
fn can_drop_data(&self, _at_position: Vector2, data: Variant) -> bool {
godot_print!("{:?}", data);
return false;
}
Am I doing something wrong, or is this a bug?
Do you get any error messages? Either in godot or if you could try running godot from the terminal/command line and see if you get any error messages there?
Here are all the messages I'm getting:
Variant(ty=String, val=test)
Variant(ty=String, val=)
Variant(ty=String, val=)
Variant(ty=String, val=)
thread '<unnamed>' panicked at 'GodotString::chars_checked: string contains invalid unicode scalar values', /home/dsoverlord/.cargo/git/checkouts/gdext-76630c89719e160c/2b6fce2/godot-core/src/builtin/string/godot_string.rs:66:18
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5
i can reproduce this at least, so it does seem like a bug, not entirely sure why it's happening though
@lilizoey @DSOverlord I think I had the same issue, see:
https://discord.com/channels/723850269347283004/1190796227235823647
I wonder if the issue is that nothing owns the variant so its memory gets freed in the meantime somehow? I tried in my example to store the object (in my case an array and in yours a string) in the Control
node which seems to avoid the crash but it still doesn't pass the correct array to drop_data
. See more details in the above discord thread.
@DSOverlord @AckslD there have been some FFI improvements/fixes in the meantime, can you still reproduce this issue?
(Well possible that yes, just want to make sure we're not tracking outdated tasks :wink: )
@Bromeon the crashes I was reproducing in this small example repo now indeed seem fixed and it does not crash anymore :rocket: So from my part this can be closed.
I also tested on my example and the glitches are fixed. So I think this issue can be closed.