Browse Source

Fix for obscure order-of-deletion problems involving self-referenctial ReferenceCountedObjectPtrs

tags/2021-05-28
jules 6 years ago
parent
commit
7ed282f314
1 changed files with 3 additions and 2 deletions
  1. +3
    -2
      modules/juce_core/memory/juce_ReferenceCountedObject.h

+ 3
- 2
modules/juce_core/memory/juce_ReferenceCountedObject.h View File

@@ -378,8 +378,9 @@ public:
/** Resets this object to a null pointer. */
void reset() noexcept
{
decIfNotNull (referencedObject);
referencedObject = nullptr;
auto oldObject = referencedObject; // need to null the pointer before deleting the object
referencedObject = nullptr; // in case this ptr is itself deleted as a side-effect
decIfNotNull (oldObject); // of the destructor
}
// the -> operator is called on the referenced object


Loading…
Cancel
Save