mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Fixed a leak in OwnedArray.
This commit is contained in:
parent
d4ae8f3d55
commit
fab78ea09e
2 changed files with 12 additions and 5 deletions
|
|
@ -142,6 +142,7 @@ public:
|
|||
#if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
|
||||
Array& operator= (Array&& other) noexcept
|
||||
{
|
||||
const ScopedLockType lock (getLock());
|
||||
data = static_cast <ArrayAllocationBase<ElementType, TypeOfCriticalSectionToUse>&&> (other.data);
|
||||
numUsed = other.numUsed;
|
||||
other.numUsed = 0;
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ public:
|
|||
*/
|
||||
~OwnedArray()
|
||||
{
|
||||
clear (true);
|
||||
deleteAllObjects();
|
||||
}
|
||||
|
||||
#if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
|
||||
|
|
@ -83,6 +83,9 @@ public:
|
|||
|
||||
OwnedArray& operator= (OwnedArray&& other) noexcept
|
||||
{
|
||||
const ScopedLockType lock (getLock());
|
||||
deleteAllObjects();
|
||||
|
||||
data = static_cast <ArrayAllocationBase <ObjectClass*, TypeOfCriticalSectionToUse>&&> (other.data);
|
||||
numUsed = other.numUsed;
|
||||
other.numUsed = 0;
|
||||
|
|
@ -97,10 +100,7 @@ public:
|
|||
const ScopedLockType lock (getLock());
|
||||
|
||||
if (deleteObjects)
|
||||
{
|
||||
while (numUsed > 0)
|
||||
delete data.elements [--numUsed];
|
||||
}
|
||||
deleteAllObjects();
|
||||
|
||||
data.setAllocatedSize (0);
|
||||
numUsed = 0;
|
||||
|
|
@ -854,6 +854,12 @@ private:
|
|||
ArrayAllocationBase <ObjectClass*, TypeOfCriticalSectionToUse> data;
|
||||
int numUsed;
|
||||
|
||||
void deleteAllObjects()
|
||||
{
|
||||
while (numUsed > 0)
|
||||
delete data.elements [--numUsed];
|
||||
}
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OwnedArray);
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue