diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 1be108d0a7..96cec568df 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -1691,10 +1691,10 @@ QProcessEnvironment QProcess::processEnvironment() const bool QProcess::waitForStarted(int msecs) { Q_D(QProcess); - if (d->processState == QProcess::Running) - return true; + if (d->processState == QProcess::Starting) + return d->waitForStarted(msecs); - return d->waitForStarted(msecs); + return d->processState == QProcess::Running; } /*! \reimp diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index f2759dfd6e..7a3f6837f8 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -154,6 +154,7 @@ private slots: void invalidProgramString(); void onlyOneStartedSignal(); void finishProcessBeforeReadingDone(); + void waitForStartedWithoutStart(); // keep these at the end, since they use lots of processes and sometimes // caused obscure failures to occur in tests that followed them (esp. on the Mac) @@ -2214,6 +2215,12 @@ void tst_QProcess::finishProcessBeforeReadingDone() QCOMPARE(lines.last(), QStringLiteral("10239 -this is a number")); } +void tst_QProcess::waitForStartedWithoutStart() +{ + QProcess process; + QVERIFY(!process.waitForStarted(5000)); +} + #endif //QT_NO_PROCESS QTEST_MAIN(tst_QProcess)