mirror of
https://github.com/godotengine/godot.git
synced 2025-11-02 22:51:08 +00:00
Rename and expose RefCounted::get_reference_count()
This commit is contained in:
parent
908795301b
commit
474cee7daf
7 changed files with 18 additions and 11 deletions
|
|
@ -1299,7 +1299,7 @@ GDNativeBool CSharpLanguage::_instance_binding_reference_callback(void *p_token,
|
|||
|
||||
MonoGCHandleData &gchandle = script_binding.gchandle;
|
||||
|
||||
int refcount = rc_owner->reference_get_count();
|
||||
int refcount = rc_owner->get_reference_count();
|
||||
|
||||
if (!script_binding.inited) {
|
||||
return refcount == 0;
|
||||
|
|
@ -1818,7 +1818,7 @@ void CSharpInstance::refcount_incremented() {
|
|||
|
||||
RefCounted *rc_owner = Object::cast_to<RefCounted>(owner);
|
||||
|
||||
if (rc_owner->reference_get_count() > 1 && gchandle.is_weak()) { // The managed side also holds a reference, hence 1 instead of 0
|
||||
if (rc_owner->get_reference_count() > 1 && gchandle.is_weak()) { // The managed side also holds a reference, hence 1 instead of 0
|
||||
// The reference count was increased after the managed side was the only one referencing our owner.
|
||||
// This means the owner is being referenced again by the unmanaged side,
|
||||
// so the owner must hold the managed side alive again to avoid it from being GCed.
|
||||
|
|
@ -1849,7 +1849,7 @@ bool CSharpInstance::refcount_decremented() {
|
|||
|
||||
RefCounted *rc_owner = Object::cast_to<RefCounted>(owner);
|
||||
|
||||
int refcount = rc_owner->reference_get_count();
|
||||
int refcount = rc_owner->get_reference_count();
|
||||
|
||||
if (refcount == 1 && !gchandle.is_weak()) { // The managed side also holds a reference, hence 1 instead of 0
|
||||
// If owner owner is no longer referenced by the unmanaged side,
|
||||
|
|
@ -1995,7 +1995,7 @@ CSharpInstance::~CSharpInstance() {
|
|||
|
||||
#ifdef DEBUG_ENABLED
|
||||
// The "instance binding" holds a reference so the refcount should be at least 2 before `scope_keep_owner_alive` goes out of scope
|
||||
CRASH_COND(rc_owner->reference_get_count() <= 1);
|
||||
CRASH_COND(rc_owner->get_reference_count() <= 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue