Skip to content

Commit 56e7ff9

Browse files
committed
Compare scripts via object_id
1 parent a2d4861 commit 56e7ff9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

godot-core/src/obj/script.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -354,15 +354,15 @@ where
354354
O: Inherits<Object>,
355355
S: Inherits<Script> + IScriptExtension + super::Bounds<Declarer = super::bounds::DeclUser>,
356356
{
357+
357358
let object_script_variant = object.upcast_ref().get_script();
358359

359360
if object_script_variant.is_nil() {
360361
return false;
361362
}
362363

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

365-
if object_script.upcast_ref::<Script>().__object_ptr() != script.upcast_ref().__object_ptr() {
365+
if object_script_variant.object_id().map(|instance_id| instance_id != script.instance_id()).unwrap_or(true) {
366366
return false;
367367
}
368368

@@ -371,6 +371,8 @@ where
371371
};
372372

373373
let get_instance_fn = sys::interface_fn!(object_get_script_instance);
374+
375+
// SAFETY: object and language are alive and their sys pointers are valid
374376
let instance = unsafe { get_instance_fn(object.obj_sys(), language.obj_sys()) };
375377

376378
!instance.is_null()

0 commit comments

Comments
 (0)