Luc4
12th July 2011, 21:50
Hi! I usually do this to free a QProcess (or a QThread after it has finished):
QProcess* proc = new QProcess();
connect(proc, SIGNAL(finished(int)), proc, SLOT(deleteLater()));
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?
QProcess* proc = new QProcess();
connect(proc, SIGNAL(finished(int)), proc, SLOT(deleteLater()));
connect(proc, SIGNAL(finished(int)), <some_pointer>, SLOT(doSomething()));
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!
QProcess* proc = new QProcess();
connect(proc, SIGNAL(finished(int)), proc, SLOT(deleteLater()));
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?
QProcess* proc = new QProcess();
connect(proc, SIGNAL(finished(int)), proc, SLOT(deleteLater()));
connect(proc, SIGNAL(finished(int)), <some_pointer>, SLOT(doSomething()));
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!