Skip to content

Godot passes an Object Variant with a null value when clearing Object subclass properties #77

Closed
@mhoff12358

Description

@mhoff12358

Given an exported property like this:

#[export(
    getter = "get_building_pattern",
    setter = "set_building_pattern",
    variant_type = "::godot::sys::VariantType::Object"
)]
building_pattern: Option<Gd<TileMapPattern>>,

with a setter like this:

#[func]
pub fn set_building_pattern(&mut self, value: Variant) {
    let converted: Result<Gd<TileMapPattern>, VariantConversionError> = value.try_to();
}

This will crash during try_to because it creates a Gd with the null pointer inside it and then it calls ready on it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions