Results 1 to 5 of 5

Thread: doubt in Qprocess.waitforfinished

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: doubt in Qprocess.waitforfinished

    QProcess::waitForFinished should return false when the QProcess ends with an error *or* the number of milliseconds is reached. It should return true only when the process is finished before the number of milliseconds are reached *and* the QProcess ended normal (return code 0).

    What is the return value from QProcess::waitForFinished and what is the QProcess::exitCode and QProcess::exitStatus? I don't believe you can do what you want by inspecting only the return value from QProcess::waitForFinished.

    IMHO, if you're going to use the QProcess::waitForFinished method, you should probably make sure your process has started by using QProcess::waitForStarted as well.
    I write the best type of code possible, code that I want to write, not code that someone tells me to write!

  2. #2
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: doubt in Qprocess.waitforfinished

    Quote Originally Posted by jefftee View Post
    QProcess::waitForFinished should return false when the QProcess ends with an error *or* the number of milliseconds is reached. It should return true only when the process is finished before the number of milliseconds are reached *and* the QProcess ended normal (return code 0).
    Really? The documentation is highly ambiguous:
    Returns true if the process finished; otherwise returns false (if the operation timed out, if an error occurred, or if this QProcess is already finished).
    I do not know what to make of this "an error occurred" condition. You seem to interpret an exit with code != 0 as such an error. From a quick look at the implementation, I believe, by contrast, that these errors are limited to internal errors (e.g. the underlying call to select() or the equivalent primitive fails).

    EDIT:
    I tested it on Linux and can confirm that waitForFinished() returns true when the process exits with a nonzero code.
    Last edited by yeye_olive; 24th September 2015 at 10:54.

  3. #3
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: doubt in Qprocess.waitforfinished

    yeye_olive, you may be correct. I've never used the waitFor* methods as I stated in my post. Agree that the doc isn't as clear as it could be, but regardless of which view is correct, the OP needs to better describe what's occurring because I surely could not tell.
    I write the best type of code possible, code that I want to write, not code that someone tells me to write!

Similar Threads

  1. Replies: 1
    Last Post: 3rd June 2013, 13:11
  2. Replies: 0
    Last Post: 23rd March 2013, 19:23
  3. QFuture waitForFinished() and result()
    By dlib in forum Qt Programming
    Replies: 1
    Last Post: 11th April 2012, 16:07
  4. Replies: 0
    Last Post: 26th August 2010, 10:44
  5. QT 4.1 in OSX I have a doubt
    By askot in forum Installation and Deployment
    Replies: 9
    Last Post: 25th February 2006, 06:14

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.