Skip to content

Commit

Permalink
Compare scripts via object_id
Browse files Browse the repository at this point in the history
  • Loading branch information
TitanNano committed Feb 7, 2025
1 parent a2d4861 commit 924483f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions godot-core/src/obj/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,10 @@ where
return false;
}

let object_script: Gd<Script> = object_script_variant.to();

if object_script.upcast_ref::<Script>().__object_ptr() != script.upcast_ref().__object_ptr() {
if object_script_variant
.object_id()
.map_or(true, |instance_id| instance_id != script.instance_id())
{
return false;
}

Expand All @@ -371,6 +372,8 @@ where
};

let get_instance_fn = sys::interface_fn!(object_get_script_instance);

// SAFETY: Object and language are alive and their sys pointers are valid.
let instance = unsafe { get_instance_fn(object.obj_sys(), language.obj_sys()) };

!instance.is_null()
Expand Down

0 comments on commit 924483f

Please sign in to comment.