title: How to delete a QProcess instance correctly?
body: <p>I have a class looking like this:</p>
  
  <pre><code>class FakeRunner : public QObject
  {
      Q_OBJECT
  private:
      QProcess* proc;
  public:
      FakeRunner();
      int run()
      {
          if (proc)
              return -1;
          proc = new QProcess();
          QStringList args;
          QString programName = "fake.exe";
  
          connect(comp, SIGNAL(started()), this, SLOT(procStarted()));
          connect(comp, SIGNAL(error(QProcess::ProcessError)), this,
                  SLOT(procError(QProcess::ProcessError)));
          connect(comp, SIGNAL(finished(int, QProcess::ExitStatus)), this,
                  SLOT(procFinished(int, QProcess::ExitStatus)));
  
          proc-&gt;start(programName, args);
  
          return 0;
      };
  
  private slots:
      void procStarted() {};
      void procFinished(int, QProcess::ExitStatus) {};
      void procError(QProcess::ProcessError);
  }
  </code></pre>
  
  <p>Since "fake.exe" does not exist on my system, proc emits the error() signal. If I handle it like following, my program crashes:</p>
  
  <pre><code>void FakeRunner::procError(QProcess::ProcessError rc)
  {
      delete proc;
      proc = 0;
  }
  </code></pre>
  
  <p>It works well, though, if I don't delete the pointer. So, the question is how (and when) should I delete the pointer to QProcess? I believe I have to delete it to avoid a memory leak. FakeRunner::run() can be invoked many times, so the leak, if there is one, will grow.</p>
  
  <p>Thanks!</p>