Good Day!

I saw a partial question and answer to this a bit ago on this list but I have a follow up scenario.

I would like to start a QProcess and connect a SLOT to its SIGNAL(error(QProcess::ProcessError))

In the SLOT, I would like to gracefully restart the process without triggering the error signal.

I have tried several ways but must be missing something. Here is some sample code that I have been tinkering with:

///////////START CODE/////////////
//in an method in the "this" object
QProcess *proc = new QProcess();
QStringList arguments;
arguments << "str1" << "str2" << "str3";
proc->setArguments(arguments);
proc->setProgram("something.exe");

connect(proc, SIGNAL(error(QProcess::ProcessError)), this, SLOT(restartProcess(QProcess::ProcessError)));
connect(proc, SIGNAL(finished(int)), proc, SLOT(deleteLater()));
proc->start();

//in the same file
void MainWindow::restartProcess(QProcess::ProcessError err)
{
    QProcess *proc = static_cast<QProcess*>(sender());

    qDebug() << "KILLING";
    proc->close();
//******
//I have used proc->kill() and proc->terminate() here as well
//******


    qDebug() << "RESTARTING";
    proc->start();
}
/////////END CODE

So, what happens is that the proc triggers an error when I kill/terminate/close it. Which triggers the function, which kills the process, which triggers the error etc etc.

In the end, not sure what is the "right" way to go about this. All I want to do is terminate and restart a process that has triggered an error.

Thoughts?

--
//-----------------------//
Jason R. Kretzer
Lead Application Developer
ja...@gocodigo.com
C:606.792.0079
H:606.297.2551
//-----------------------//
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to