Skip to content

Commit 29f58ff

Browse files
committed
Compare scripts via object_id
1 parent a2d4861 commit 29f58ff

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

godot-core/src/obj/script.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,11 @@ 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(|instance_id| instance_id != script.instance_id())
366+
.unwrap_or(true)
367+
{
366368
return false;
367369
}
368370

@@ -371,6 +373,8 @@ where
371373
};
372374

373375
let get_instance_fn = sys::interface_fn!(object_get_script_instance);
376+
377+
// SAFETY: object and language are alive and their sys pointers are valid
374378
let instance = unsafe { get_instance_fn(object.obj_sys(), language.obj_sys()) };
375379

376380
!instance.is_null()

0 commit comments

Comments
 (0)