diff --git a/modules/juce_core/containers/juce_Array.h b/modules/juce_core/containers/juce_Array.h index 6940344620..df2b5a82f8 100644 --- a/modules/juce_core/containers/juce_Array.h +++ b/modules/juce_core/containers/juce_Array.h @@ -728,6 +728,7 @@ public: if (isPositiveAndBelow (indexToRemove, numUsed)) { + jassert (data.elements != nullptr); ElementType removed (data.elements[indexToRemove]); removeInternal (indexToRemove); return removed; diff --git a/modules/juce_core/containers/juce_ReferenceCountedArray.h b/modules/juce_core/containers/juce_ReferenceCountedArray.h index c792d8766c..59a3bcb63a 100644 --- a/modules/juce_core/containers/juce_ReferenceCountedArray.h +++ b/modules/juce_core/containers/juce_ReferenceCountedArray.h @@ -293,7 +293,7 @@ public: @param newObject the new object to add to the array @see set, insert, addIfNotAlreadyThere, addSorted, addArray */ - void add (ObjectClass* const newObject) noexcept + ObjectClass* add (ObjectClass* const newObject) noexcept { const ScopedLockType lock (getLock()); data.ensureAllocatedSize (numUsed + 1); @@ -302,6 +302,8 @@ public: if (newObject != nullptr) newObject->incReferenceCount(); + + return newObject; } /** Inserts a new object into the array at the given index. @@ -317,8 +319,8 @@ public: @param newObject the new object to add to the array @see add, addSorted, addIfNotAlreadyThere, set */ - void insert (int indexToInsertAt, - ObjectClass* const newObject) noexcept + ObjectClass* insert (int indexToInsertAt, + ObjectClass* const newObject) noexcept { if (indexToInsertAt >= 0) { @@ -342,10 +344,12 @@ public: newObject->incReferenceCount(); ++numUsed; + + return newObject; } else { - add (newObject); + return add (newObject); } }