Skip to content

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

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

Closed
lmsonic opened this issue Sep 2, 2024 · 2 comments
Labels
status: duplicate This issue or pull request already exists

Comments

@lmsonic
Copy link

lmsonic commented Sep 2, 2024

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
@Bromeon
Copy link
Member

Bromeon commented Sep 2, 2024

Please search for existing issues before opening new ones (e.g. edit yields it):
#494

@Bromeon Bromeon closed this as not planned Won't fix, can't repro, duplicate, stale Sep 2, 2024
@Bromeon Bromeon added the status: duplicate This issue or pull request already exists label Sep 2, 2024
@Bromeon
Copy link
Member

Bromeon commented Sep 3, 2024

Now fixed by #883.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants