Browse Source

Added an assertion to ScopedPointer to catch people resetting it to itself

tags/2021-05-28
ed 7 years ago
parent
commit
ddc2f9cc4c
1 changed files with 6 additions and 0 deletions
  1. +6
    -0
      modules/juce_core/memory/juce_ScopedPointer.h

+ 6
- 0
modules/juce_core/memory/juce_ScopedPointer.h View File

@@ -162,6 +162,12 @@ public:
object = newObject;
ContainerDeletePolicy<ObjectType>::destroy (oldObject);
}
else
{
// You're trying to reset this ScopedPointer to itself! This will work here as ScopedPointer does an equality check
// but be aware that std::unique_ptr won't do this and you could end up with some nasty, subtle bugs!
jassertfalse;
}
}
/** Sets this pointer to a new object, deleting the old object that it was previously pointing to if there was one. */


Loading…
Cancel
Save