QProcess: Destroyed while process is still running.



  • Hi,

    Everytime I try to use a QProcess object I get the message: QProcess: Destroyed while process is still running.

    I have tried two different ways:
    @
    QProcess *proc = new QProcess(this);
    proc->start("executeScene.sh", QStringList() << "1" << "0.16");

    QProcess proc2;
    proc2.start("executeScene.sh", QStringList() << "1" << "0.16");
    @
    but the result is the same. Any suggestion?



  • Are you deleting it before the started process has ended?



  • Please show us a bit more of the sorounding code
    I'm sure you delete it.

    if you do the following, it's wrong:

    @
    foo()
    {
    QProcess proc2;
    proc2.start("executeScene.sh", QStringList() << "1" << "0.16");
    }
    @

    If you do it like this, it should work, but blocks the event loop (this code comes from the docs of "QProcess":http://doc.qt.nokia.com/latest/qprocess.html ):

    @
    foo()
    {
    QProcess gzip;
    gzip.start("gzip", QStringList() << "-c");
    if (!gzip.waitForStarted())
    return false;

     gzip.write("Qt rocks!");
     gzip.closeWriteChannel();
    
     if (!gzip.waitForFinished())
         return false;
    
     QByteArray result = gzip.readAll();
    

    }
    @



  • If you create the process variable on stack, it will be deleted when you go out of scope, unless you explicitely synchronize to wait until process is finished.

    Just for testing, replace your QProcess by a QProcess*, most probably

    • you'll have a leak
    • the message will disappear

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.