Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    QProcess: Destroyed while process is still running.

    General and Desktop
    4
    4
    25896
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B
      bautistaeric last edited by

      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?

      1 Reply Last reply Reply Quote 0
      • D
        dangelog last edited by

        Are you deleting it before the started process has ended?

        Software Engineer
        KDAB (UK) Ltd., a KDAB Group company

        1 Reply Last reply Reply Quote 0
        • G
          giesbert last edited by

          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();
          

          }
          @

          Nokia Certified Qt Specialist.
          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

          1 Reply Last reply Reply Quote 0
          • F
            florent.revelut last edited by

            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
            1 Reply Last reply Reply Quote 0
            • First post
              Last post