Refactoring. Treat waitForFinished more carefully. Use QScopedPointer for

pointer to QProcess.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-07-30 18:17:43 +03:00
parent fa2e0b13d0
commit 35dee8dafb
2 changed files with 3 additions and 3 deletions

View File

@ -284,7 +284,7 @@ bool DialogSaveLayout::TestPdf()
#else #else
proc.start(PDFTOPS); // Seek pdftops in standard path proc.start(PDFTOPS); // Seek pdftops in standard path
#endif #endif
if (proc.waitForFinished(15000)) if (proc.waitForFinished(15000) || proc.state() == QProcess::NotRunning)
{ {
res = true; res = true;
} }

View File

@ -93,7 +93,7 @@ bool AbstractTest::Run(bool showWarn, int exit, int &exitCode, const QString &pr
return false; return false;
} }
QProcess *process = new QProcess(this); QScopedPointer<QProcess> process(new QProcess());
process->setWorkingDirectory(info.absoluteDir().absolutePath()); process->setWorkingDirectory(info.absoluteDir().absolutePath());
process->start(program, arguments); process->start(program, arguments);
@ -102,6 +102,7 @@ bool AbstractTest::Run(bool showWarn, int exit, int &exitCode, const QString &pr
const QString msg = QString("The operation timed out or an error occurred.\n%1").arg(parameters); const QString msg = QString("The operation timed out or an error occurred.\n%1").arg(parameters);
QWARN(qUtf8Printable(msg)); QWARN(qUtf8Printable(msg));
exitCode = TST_EX_TIME_OUT; exitCode = TST_EX_TIME_OUT;
process->kill();
return false; return false;
} }
@ -126,7 +127,6 @@ bool AbstractTest::Run(bool showWarn, int exit, int &exitCode, const QString &pr
} }
exitCode = process->exitCode(); exitCode = process->exitCode();
delete process;
return true; return true;
} }