I am using QSharedPointer for an object which contains slot function. My expectation is that even though the object that contains this pointer get destroyed but it would live on and process the QProcess::finished
signal but it doesn't.
I create a QProcess
and connect it to slot. The Pdf object will soon get destroyed though so I using QSharedPointer so m_symLinks
object stays alive and process the finished
signal but it dies too before processing it.
void PDf::createPDF()
{
// ....
QProcess *myProcess= new QProcess();
connect(myProcess, SIGNAL(finished(int)), m_symlinks.data(), SLOT(createPdfLink(int)) );
myProcess->start("sh",args); // yes args is valid variable defined (now shown)
// note if I waitForFinished() here than my slot does get called but the slot object seems to die if I don't wait here.
}
The header file is:
class Pdf: public QObject
{
Q_OBJECT
Pdf() : QObject(parent)
{
m_symlinks = (QSharedPointer <Symlinks>) (new Symlinks);
}
QSharedPointer <Symlinks> m_symlinks;
}