Fix crash when copying a WeakPointerTo that was already deleted
This commit is contained in:
parent
e6d29d6f51
commit
265bf42f81
|
|
@ -319,6 +319,9 @@ get_weak_list() const {
|
|||
INLINE void ReferenceCount::
|
||||
weak_ref(WeakPointerToVoid *ptv) {
|
||||
TAU_PROFILE("void ReferenceCount::weak_ref()", " ", TAU_USER);
|
||||
#ifdef _DEBUG
|
||||
nassertv(test_ref_count_integrity());
|
||||
#endif
|
||||
get_weak_list()->add_reference(ptv);
|
||||
}
|
||||
|
||||
|
|
@ -332,6 +335,9 @@ weak_ref(WeakPointerToVoid *ptv) {
|
|||
INLINE void ReferenceCount::
|
||||
weak_unref(WeakPointerToVoid *ptv) {
|
||||
TAU_PROFILE("void ReferenceCount::weak_unref()", " ", TAU_USER);
|
||||
#ifdef _DEBUG
|
||||
nassertv(test_ref_count_integrity());
|
||||
#endif
|
||||
nassertv(has_weak_list());
|
||||
((WeakReferenceList *)_weak_list)->clear_reference(ptv);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ WeakPointerTo(const PointerTo<T> ©) :
|
|||
template<class T>
|
||||
INLINE WeakPointerTo<T>::
|
||||
WeakPointerTo(const WeakPointerTo<T> ©) :
|
||||
WeakPointerToBase<T>(*(const PointerToBase<T> *)©)
|
||||
WeakPointerToBase<T>(*(const WeakPointerToBase<T> *)©)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -194,7 +194,7 @@ WeakConstPointerTo(const ConstPointerTo<T> ©) :
|
|||
template<class T>
|
||||
INLINE WeakConstPointerTo<T>::
|
||||
WeakConstPointerTo(const WeakPointerTo<T> ©) :
|
||||
WeakPointerToBase<T>(*(const PointerToBase<T> *)©)
|
||||
WeakPointerToBase<T>(*(const WeakPointerToBase<T> *)©)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -206,7 +206,7 @@ WeakConstPointerTo(const WeakPointerTo<T> ©) :
|
|||
template<class T>
|
||||
INLINE WeakConstPointerTo<T>::
|
||||
WeakConstPointerTo(const WeakConstPointerTo<T> ©) :
|
||||
WeakPointerToBase<T>(*(const PointerToBase<T> *)©)
|
||||
WeakPointerToBase<T>(*(const WeakPointerToBase<T> *)©)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,13 @@ WeakPointerToBase(const PointerToBase<T> ©) {
|
|||
template<class T>
|
||||
INLINE WeakPointerToBase<T>::
|
||||
WeakPointerToBase(const WeakPointerToBase<T> ©) {
|
||||
reassign(copy);
|
||||
_void_ptr = copy._void_ptr;
|
||||
_ptr_was_deleted = copy._ptr_was_deleted;
|
||||
|
||||
if (is_valid_pointer()) {
|
||||
To *ptr = (To *)_void_ptr;
|
||||
ptr->weak_ref(this);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
Loading…
Reference in New Issue