Hello,

I'm creating a simple watchdog program that watches a process. If the process exits or crashes I want to restart the process. My dialog has a program exe and working directory line edits, for program selection, along with Start/Stop/Restart buttons. It has a QTimer for automatically restarting a crashed/exited program after N seconds.

My program functions as a systray icon that provides message bubbles based on the status or any crash/exit events. So I have the QProcess signals connected like this in my dialog's constructor:
Qt Code:
  1. process = new QProcess();
  2. connect(process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(handleProcessError(QProcess::ProcessError)));
  3. connect(process, SIGNAL(finished(int, QProcess::ExitStatus )), this, SLOT(handleProcessFinish(int, QProcess::ExitStatus)));
To copy to clipboard, switch view to plain text mode 

When pushing the stop button, I want to kill the process with QProcess::kill(). When the process is killed, naturally, the handleProcessError slot gets called and I do not want this. I wanted to disable this by using:
Qt Code:
  1. disconnect(process, SIGNAL(error(QProcess::ProcessError)), 0, 0);
  2. disconnect(process, SIGNAL(finished(int exitCode, QProcess::ExitStatus exitStatus)), 0,0);
  3. process->kill();
To copy to clipboard, switch view to plain text mode 

I've also tried calling:
Qt Code:
  1. process->disconnect();
  2. process->kill();
To copy to clipboard, switch view to plain text mode 
in an attempt to blindly disconnect everything.

It appears after calling these disconnect calls the error signal is not actually disconnected as I still get my message bubble popping up telling me that the program has crashed. Furthermore, my handleProcessError slot is designed to call my restart QTimer::start() so that the program will automatically restart.

My hopes to disconnect it have failed and when the user clicks "Stop" I do not want the program to automatically restart. This has led me to deleting the QProcess object, and creating a new instance.

Any ideas as to why the signals are not getting disconnected?

Using Qt 4.5.1 with VS2008

Thanks,
Darryl