0

I am running a Qt app that launches a process. (The Assistant, launched from the main app).

When I close the app, I get the warning

QProcess: Destroyed while process is still running.

How can I get rid of it ?

I saw this similar question and tried to kill... Nothing happened.

This question seems to say maybe I should add waitForFinished()... Help won't close when app does.

Help::Help():m_helpProcess(0) {}

Help::~Help()
{
  if (m_helpProcess) {
    m_helpProcess.waitForFinished();   // help stays open after app closes
    m_helpProcess->kill();   // added with no effect
    delete m_helpProcess;
  }
}

bool Help::start() 
{
  if (!m_helpProcess)
      process = new QProcess();
  QStringList args;
  args << QLatin1String("-collectionFile")
       << QLatin1String("mycollection.qhc");
  process->start(QLatin1String("Assistant.app"), args);
  if (!process->waitForStarted())
      return;
}
Community
  • 1
  • 1
Thalia
  • 13,637
  • 22
  • 96
  • 190

1 Answers1

1

It should be sufficient to rewrite the destructor using close():

Closes all communication with the process and kills it. After calling this function, QProcess will no longer emit readyRead(), and data can no longer be read or written.

Help::~Help()
{
    if (m_helpProcess) {
        // m_helpProcess->waitForFinished();   // help stays open after app closes
        m_helpProcess->close();                // close channels
        delete m_helpProcess;                  // destructor actually kills the process  
    }
}
BaCaRoZzo
  • 7,502
  • 6
  • 51
  • 82