Skip to content

Panic when using to_init_gd in RefCounted when opening Godot editor #1296

@beicause

Description

@beicause
#[derive(GodotClass)]
#[class(base=RefCounted)]
pub struct MyRefCounted {
    base: Base<RefCounted>,
    #[export]
    some_string: GString,
}

#[godot_api]
impl IRefCounted for MyRefCounted {
    fn init(base: Base<RefCounted>) -> Self {
        let sf = base.to_init_gd();
        Self {
            base,
            some_string: "".into(),
        }
    }
}

Godot editor trys to generate docs for the class:
Image

However, ClassDB::class_get_default_property_value instantiates the object and immediately delete it, which causes drop_strong_ref to panic, see the source code in: https://github.com/godotengine/godot/blob/6339f31a0217038ce6ed5e16776e34654895edc6/core/object/class_db.cpp#L2220-L2240

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions