TStrongObjectPtr
Owning handle that adds its referent to FMObjectArray's root set, so the GC can't sweep it out from under us. Use when a non-MObject holder needs to keep an MObject alive without being its Outer; an MObject reached through the Outer chain or an MPROPERTY needs no explicit root. Copyable: the root set counts, so every copy is one more owner and the object stays rooted until the last one lets go — including an owner that rooted it by hand.
- Module
- Core
- Header
#include "Core/TObjectPtr.h"- Namespace
Mowo- Template
template<typename T>
Destroy still wins (a pending-kill root is collected, as it always was). The handle remembers the slot's serial, so after that sweep Get() answers null and letting go touches nothing, instead of reading freed memory.
Constructors
| Signature | Name | Description |
|---|---|---|
constexpr TStrongObjectPtr() = default | TStrongObjectPtr | |
explicit TStrongObjectPtr(T* p) | TStrongObjectPtr | |
TStrongObjectPtr(const TStrongObjectPtr& other) | TStrongObjectPtr | |
TStrongObjectPtr(TStrongObjectPtr&& other) noexcept : m_ptr(other.m_ptr), m_inde… | TStrongObjectPtr | |
~TStrongObjectPtr() | ~TStrongObjectPtr |
Public functions
| Returns | Name | Description |
|---|---|---|
TStrongObjectPtr& | operator= | |
TStrongObjectPtr& | operator= | |
T* | Get | |
T& | operator* | |
T* | operator-> | |
operatorbool | ||
void | Reset | |
T* | Release | Give up this handle's share of the root and hand the pointer back. |
Function details
TStrongObjectPtr
constexpr TStrongObjectPtr() = defaultTStrongObjectPtr
explicit TStrongObjectPtr(T* p)TStrongObjectPtr
TStrongObjectPtr(const TStrongObjectPtr& other)TStrongObjectPtr
TStrongObjectPtr(TStrongObjectPtr&& other) noexcept : m_ptr(other.m_ptr), m_index(other.m_index), m_serial(other.m_serial)~TStrongObjectPtr
~TStrongObjectPtr()operator=
TStrongObjectPtr& operator=(const TStrongObjectPtr& other)operator=
TStrongObjectPtr& operator=(TStrongObjectPtr&& other) noexceptGet
T* Get() const noexceptoperator*
T& operator*() constoperator->
T* operator->() constoperatorbool
explicit operator bool() const noexceptReset
void Reset()Release
T* Release()Give up this handle's share of the root and hand the pointer back. The object stays rooted only if another owner still roots it.