Skip to content

Propagate panics in object constructors to Gd::from_init_fn(), new_gd(), new_alloc() #1140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 27, 2025

Conversation

Bromeon
Copy link
Member

@Bromeon Bromeon commented Apr 24, 2025

Closes #919.

User-facing APIs to construct Gd objects -- either via default constructor or via Gd::from_init_fn() -- now propagate any panics occurring in init() or the passed init_fn 1:1 to the caller.

In GDScript, constructing a Rust instance whose constructor panics will yield null.

@Bromeon Bromeon added quality-of-life No new functionality, but improves ergonomics/internals c: core Core components c: ffi Low-level components and interaction with GDExtension API labels Apr 24, 2025
@Bromeon Bromeon force-pushed the bugfix/init-unhandled-panic branch from a4e4446 to e9d517b Compare April 24, 2025 22:25
@Bromeon
Copy link
Member Author

Bromeon commented Apr 24, 2025

Might need some more testing in the editor, to see whether panics are actually printed (even when used from GDScript).
Could also be postponed after 0.3.0.

@GodotRust
Copy link

API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-1140

@Bromeon Bromeon added this to the 0.3 milestone Apr 27, 2025
@Bromeon Bromeon added this pull request to the merge queue Apr 27, 2025
Merged via the queue into master with commit 08f24dc Apr 27, 2025
16 checks passed
@Bromeon Bromeon deleted the bugfix/init-unhandled-panic branch April 27, 2025 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: core Core components c: ffi Low-level components and interaction with GDExtension API quality-of-life No new functionality, but improves ergonomics/internals
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Panic in init function does not catch unwind and crashes editor
2 participants