Hi! I usually do this to free a QProcess (or a QThread after it has finished):
connect(proc, SIGNAL(finished(int)), proc, SLOT(deleteLater()));
QProcess* proc = new QProcess();
connect(proc, SIGNAL(finished(int)), proc, SLOT(deleteLater()));
To copy to clipboard, switch view to plain text mode
and seems to work just fine, and I suppose is the correct way of freeing memory. Am I right?
Now, I find myself in the situation where I need to do something after the process has finished, but I also want to delete the pointer. Can I do this?
connect(proc, SIGNAL(finished(int)), proc, SLOT(deleteLater()));
connect(proc, SIGNAL(finished(int)), <some_pointer>, SLOT(doSomething()));
QProcess* proc = new QProcess();
connect(proc, SIGNAL(finished(int)), proc, SLOT(deleteLater()));
connect(proc, SIGNAL(finished(int)), <some_pointer>, SLOT(doSomething()));
To copy to clipboard, switch view to plain text mode
I tried this and it seems to work but I don't know if it is the correct way to go. If it isn't, what is the best solution?
Thanks!
Bookmarks