mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-20 12:50:57 +00:00
working weak ref
WeakRefPtr now actually acts like a weak reference backend of weakRefPtr is now a weak_ptr so once the main shared_ptr is freed, they all get freed.
This commit is contained in:
parent
d688f1cfde
commit
ca4517c076
4 changed files with 56 additions and 82 deletions
|
|
@ -1054,30 +1054,16 @@ public:
|
|||
typedef WeakRefPtr< T > Parent;
|
||||
|
||||
SimObjectPtr() = default;
|
||||
SimObjectPtr(T *ptr) { set(ptr); }
|
||||
SimObjectPtr( const SimObjectPtr& ref ) { this->mReference = ref.mReference; }
|
||||
SimObjectPtr(T* ptr) : Parent(ptr) {}
|
||||
SimObjectPtr(const SimObjectPtr&) = default;
|
||||
SimObjectPtr& operator=(const SimObjectPtr&) = default;
|
||||
SimObjectPtr& operator=(T* ptr)
|
||||
{
|
||||
Parent::operator=(ptr);
|
||||
return *this;
|
||||
}
|
||||
|
||||
T* getObject() const { return Parent::getPointer(); }
|
||||
|
||||
~SimObjectPtr() { this->mReference = NULL; }
|
||||
|
||||
SimObjectPtr<T>& operator=(const SimObjectPtr ref)
|
||||
{
|
||||
this->mReference = ref.mReference;
|
||||
return *this;
|
||||
}
|
||||
SimObjectPtr<T>& operator=(T *ptr)
|
||||
{
|
||||
set(ptr);
|
||||
return *this;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
void set(T * obj)
|
||||
{
|
||||
this->mReference = obj ? obj->getWeakReference() : NULL;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _SIMOBJECT_H_
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue