Skip to content

Commit 7dad97c

Browse files
authored
Merge pull request #1036 from TitanNano/master
Compare scripts via object_id
2 parents 6cb37a8 + 924483f commit 7dad97c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

godot-core/src/obj/script.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,10 @@ where
360360
return false;
361361
}
362362

363-
let object_script: Gd<Script> = object_script_variant.to();
364-
365-
if object_script.upcast_ref::<Script>().__object_ptr() != script.upcast_ref().__object_ptr() {
363+
if object_script_variant
364+
.object_id()
365+
.map_or(true, |instance_id| instance_id != script.instance_id())
366+
{
366367
return false;
367368
}
368369

@@ -371,6 +372,8 @@ where
371372
};
372373

373374
let get_instance_fn = sys::interface_fn!(object_get_script_instance);
375+
376+
// SAFETY: Object and language are alive and their sys pointers are valid.
374377
let instance = unsafe { get_instance_fn(object.obj_sys(), language.obj_sys()) };
375378

376379
!instance.is_null()

0 commit comments

Comments
 (0)