I am wondering if i need to disconnect singals and slots if i destroy the signal emitting object. Here is an example:
QAudioOutput * audioOutput = new QAudioOutput(format,mainWindow);
connect(audioOutput,SIGNAL(stateChanged(QAudio::State)),this,SLOT(stateChanged(QAudio::State)));
delete audioOutput;
audioOutput = new QAudioOutput(format,mainWindow);
connect(audioOutput,SIGNAL(stateChanged(QAudio::State)),this,SLOT(stateChanged(QAudio::State)));
Will this automatically disconnect the signal from the old audioOutput, or will it lead to mem leaks or some other undefined behavior ?
Thank you in advance.
The signals are automatically disconnected when you call the QObject destructor. Have a look at the Qt documentation: QObject Destructor