| 1711 | } |
| 1712 | |
| 1713 | bool 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 | |
| 1734 | bool CSharpInstance::_unreference_owner_unsafe() { |
| 1735 | #ifdef DEBUG_ENABLED |
no test coverage detected