So I have an OwnedArray of MemoryInputStream
OwnedArray<MemoryInputStream> streamArray;
and I iterate through them…
for (int j = 0; j < numFiles; ++j)
{
FlacAudioFormat flac;
MemoryInputStream* pis = streamArray[j];
AudioFormatReader* pReader = flac.createReaderFor (pis, true);
if (pReader != nullptr)
{
pReader->setDeleteStreamOnExitFlag (false); // My method
// Do some stuff....
delete pReader;
}
}
the problem is that when the array goes out of scope and attempts to delete the objects – they no longer exist.
I added a public method and changed the destructor to:
AudioFormatReader::~AudioFormatReader()
{
if (deleteInputStreamOnExit)
delete input;
}
which fixes the issue…
For backward compatibility deleteInputStreamOnExit is initialized to true.
Is this something you’d consider adding?
Thanks,
Rail
