Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QProcess: Destroyed while process is still running.
Forum Updated to NodeBB v4.3 + New Features

QProcess: Destroyed while process is still running.

Scheduled Pinned Locked Moved General and Desktop
4 Posts 4 Posters 28.3k Views 1 Watching
  • 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 Offline
    B Offline
    bautistaeric
    wrote on last edited by
    #1

    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
    0
    • D Offline
      D Offline
      dangelog
      wrote on last edited by
      #2

      Are you deleting it before the started process has ended?

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

      1 Reply Last reply
      0
      • G Offline
        G Offline
        giesbert
        wrote on last edited by
        #3

        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
        0
        • F Offline
          F Offline
          florent.revelut
          wrote on last edited by
          #4

          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
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved