mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-11 23:54:18 +00:00
SafePointer: Avoid potential double-deletes
deleteAndZero now behaves more like unique_ptr::reset, which sets the new stored value before freeing the old one.
This commit is contained in:
parent
5d2b1b7aa7
commit
aeeb06ccb9
1 changed files with 1 additions and 1 deletions
|
|
@ -2344,7 +2344,7 @@ public:
|
|||
ComponentType* operator->() const noexcept { return getComponent(); }
|
||||
|
||||
/** If the component is valid, this deletes it and sets this pointer to null. */
|
||||
void deleteAndZero() { delete getComponent(); }
|
||||
void deleteAndZero() { delete std::exchange (weakRef, nullptr); }
|
||||
|
||||
bool operator== (ComponentType* component) const noexcept { return weakRef == component; }
|
||||
bool operator!= (ComponentType* component) const noexcept { return weakRef != component; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue