godot-rust / godot-rust/gdext

`self.to_gd()` in `drop()` causes (double) panic

Open
#1,245 4 comments 0 reactions 0 assignees View on GitHub
c: register feature
Dominant language
Rust
Stars
5.2k
Forks
312
Avg merge
12h 59m
Merged PRs (30d)
9

Description

Maybe the inverse problem of #557.

```
#[derive(GodotClass)]
#[class(init, base=RefCounted)]
struct AccessGdOnDrop {
base: Base,
}

impl Drop for AccessGdOnDrop {
fn drop(&mut self) {
// This causes a panic.
self.to_gd();
}
}

#[itest]
fn access_gd_on_drop() {
let obj = AccessGdOnDrop::new_gd();
drop(obj);
}
```

This gives a panic (message copied from my actual game, the above seems to outright abort):

ERROR: [panic .../godot-core-0.3.1/src/obj/raw_gd.rs:201]
object expected to inherit RefCounted

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.