Skip to content

EditorScript _edit() method can receive null objects but the signature in gdext is Gd<Object> instead of Option<Gd<Object>> #880

Closed as not planned
@lmsonic

Description

@lmsonic

The method _edit(object:Object) in EditorScript can accept null values, but the API in gdext accepts Gd<Object> which cannot be null
This is my usage right now, but it gives me errors in any case on the godot side:

fn edit(&mut self, object: Gd<Object>) {
        if !object.is_instance_valid() {
            return;
        }
        if let Ok(curve) = object.try_cast() {
            self.curve = Some(curve);
        }
    }

Error:

C:\Users\<REDACTED>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\godot-core-0.1.3\src\private.rs:313 - godot-rust function call failed: SolidCurve2DEditorPlugin::edit()
      Reason: [panic]  in function `SolidCurve2DEditorPlugin::edit` at parameter [0] of type godot_core::obj::gd::Gd<godot_core::gen::classes::object::re_export::Object>: `Gd` cannot be null: null

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: duplicateThis issue or pull request already exists

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions