PDA

View Full Version : Memory management with QAudioOutput



hackerNovitiate
17th January 2012, 18:00
Hi all, I'm writing a program that uses QAudioOutput::start(), which returns a QIODevice pointer. Does this device need to be manually deleted later? The class reference page doesn't seem to indicate either way.

hackerNovitiate
20th January 2012, 01:41
I found the answer.



QAudioOutput *audioOutput = new QAudioOutput(myAudioFormat, this);
QIODevice *ioDevice = audioOutput->start();
qDebug() << "Parent is" << ioDevice->parent();

...gives the following:


Parent is QObject(0x0)

So nobody owns the QIODevice, so it has to be manually deleted.

EDIT: Nope, I was mistaken... even though nobody owns the QIODevice, it still gets automatically deleted when QAudioOutput::stop() is called.