Results 1 to 5 of 5

Thread: doubt in Qprocess.waitforfinished

  1. #1
    Join Date
    Nov 2014
    Location
    Chennai
    Posts
    160
    Thanks
    65
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default doubt in Qprocess.waitforfinished

    am doing HLS conversion using Qprocess,hls conversion takes 20 minutes,if it takes above 20 minutes i should through error,and return back to mainscreen.here my problem is when hls conversion fails below20 minutes,my Qprocess waits for 20 minutes after reaches 20 minutes it stops the hls conversion it not showing error
    Qt Code:
    1. bool status;
    2. QProcess process;
    3. QStringList arguments;
    4. QString program ="/bin/sh";
    5. arguments << SCRIPTFILEPATH;
    6. process.start(program, arguments);
    7. status=process.waitForFinished(waitminutes); //waitminute contains =1200000
    8. qDebug()<<status<<"status for Qprocess";
    9. if(!status)
    10. {
    11. errorstatus("Movie Conversion has Errors. Check the DVD Media ");
    12. return FAIL;
    13. }
    14. return SUCCESS;
    To copy to clipboard, switch view to plain text mode 
    i know am doing mistakes here please kindly help me to rectify my problems
    Thanks in advance

  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

    Your code lets the process run for at most 20 minutes. If the process terminates or crashes within 20 minutes, your code returns SUCCESS as soon as that happens. Otherwise it returns FAIL when the 20 minutes have elapsed.

    What do you mean by "hls conversion fails below20 minutes"? Do you mean that the process terminates before the 20 minutes have elapsed, but has not successfully performed the task you expected?

    Please note that QProcess does not know anything about the task performed by the process. It cannot distinguish between a process that terminates, having successfully performed its expected task, and a process that terminates, having failed to do so. All it knows it whether the process has terminated or crashed and, if it has terminated, its exit code.

  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

    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!

  4. #4
    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.

  5. #5
    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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.