mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 00:32:57 -04:00
Protect against self-move-assignment to fix stable_sort in MSVC
This commit is contained in:
parent
828e52578d
commit
dafae50ce2
@ -71,14 +71,17 @@ PointerToBase(PointerToBase<T> &&from) NOEXCEPT {
|
||||
template<class T>
|
||||
INLINE void PointerToBase<T>::
|
||||
reassign(PointerToBase<T> &&from) NOEXCEPT {
|
||||
To *old_ptr = (To *)this->_void_ptr;
|
||||
// Protect against self-move-assignment.
|
||||
if (from._void_ptr != this->_void_ptr) {
|
||||
To *old_ptr = (To *)this->_void_ptr;
|
||||
|
||||
this->_void_ptr = from._void_ptr;
|
||||
from._void_ptr = NULL;
|
||||
this->_void_ptr = from._void_ptr;
|
||||
from._void_ptr = NULL;
|
||||
|
||||
// Now delete the old pointer.
|
||||
if (old_ptr != (To *)NULL) {
|
||||
unref_delete(old_ptr);
|
||||
// Now delete the old pointer.
|
||||
if (old_ptr != (To *)NULL) {
|
||||
unref_delete(old_ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // USE_MOVE_SEMANTICS
|
||||
|
@ -102,12 +102,15 @@ CopyOnWritePointer(CopyOnWritePointer &&move) NOEXCEPT :
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void CopyOnWritePointer::
|
||||
operator = (CopyOnWritePointer &&move) NOEXCEPT {
|
||||
CopyOnWriteObject *old_object = _cow_object;
|
||||
_cow_object = move._cow_object;
|
||||
move._cow_object = NULL;
|
||||
// Protect against self-move-assignment.
|
||||
if (move._cow_object != _cow_object) {
|
||||
CopyOnWriteObject *old_object = _cow_object;
|
||||
_cow_object = move._cow_object;
|
||||
move._cow_object = NULL;
|
||||
|
||||
if (old_object != (CopyOnWriteObject *)NULL) {
|
||||
cache_unref_delete(old_object);
|
||||
if (old_object != (CopyOnWriteObject *)NULL) {
|
||||
cache_unref_delete(old_object);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // USE_MOVE_SEMANTICS
|
||||
|
Loading…
x
Reference in New Issue
Block a user