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

Method _reference_owner_unsafe

modules/mono/csharp_script.cpp:1713–1732  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1711}
1712
1713bool CSharpInstance::_reference_owner_unsafe() {
1714#ifdef DEBUG_ENABLED
1715 CRASH_COND(!base_ref_counted);
1716 CRASH_COND(owner == nullptr);
1717 CRASH_COND(unsafe_referenced); // already referenced
1718#endif // DEBUG_ENABLED
1719
1720 // Unsafe refcount increment. The managed instance also counts as a reference.
1721 // This way if the unmanaged world has no references to our owner
1722 // but the managed instance is alive, the refcount will be 1 instead of 0.
1723 // See: _unreference_owner_unsafe()
1724
1725 // May not be referenced yet, so we must use init_ref() instead of reference()
1726 if (static_cast<RefCounted *>(owner)->init_ref()) {
1727 CSharpLanguage::get_singleton()->post_unsafe_reference(owner);
1728 unsafe_referenced = true;
1729 }
1730
1731 return unsafe_referenced;
1732}
1733
1734bool CSharpInstance::_unreference_owner_unsafe() {
1735#ifdef DEBUG_ENABLED

Calls 2

init_refMethod · 0.80
post_unsafe_referenceMethod · 0.80

Tested by

no test coverage detected