MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / ref_pointer

Method ref_pointer

core/variant/variant.cpp:637–658  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

635}
636
637void Variant::ObjData::ref_pointer(Object *p_object, bool p_is_weak_ref_old, bool p_is_weak_ref) {
638 // Mirrors Ref::ref_pointer in refcounted.h
639 if (p_object == obj) {
640 return;
641 }
642
643 ObjData cleanup_ref = *this;
644
645 if (p_object) {
646 *this = ObjData{ p_object->get_instance_id(), p_object };
647 if (!p_is_weak_ref && p_object->is_ref_counted()) {
648 RefCounted *reference = static_cast<RefCounted *>(p_object);
649 if (!reference->init_ref()) {
650 *this = ObjData();
651 }
652 }
653 } else {
654 *this = ObjData();
655 }
656
657 cleanup_ref.unref(p_is_weak_ref_old);
658}
659
660void Variant::ObjData::unref(bool p_is_weak_ref) {
661 // Mirrors Ref::unref in refcounted.h

Callers 2

VariantMethod · 0.45
object_assignMethod · 0.45

Calls 5

ObjDataClass · 0.85
init_refMethod · 0.80
get_instance_idMethod · 0.45
is_ref_countedMethod · 0.45
unrefMethod · 0.45

Tested by

no test coverage detected