From 35dee8dafbe89476d1066ee034e1d8f35e3a89d1 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sat, 30 Jul 2016 18:17:43 +0300 Subject: [PATCH] Refactoring. Treat waitForFinished more carefully. Use QScopedPointer for pointer to QProcess. --HG-- branch : develop --- src/app/valentina/dialogs/dialogsavelayout.cpp | 2 +- src/test/ValentinaTest/abstracttest.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/valentina/dialogs/dialogsavelayout.cpp b/src/app/valentina/dialogs/dialogsavelayout.cpp index 3e6415850..c1eae6432 100644 --- a/src/app/valentina/dialogs/dialogsavelayout.cpp +++ b/src/app/valentina/dialogs/dialogsavelayout.cpp @@ -284,7 +284,7 @@ bool DialogSaveLayout::TestPdf() #else proc.start(PDFTOPS); // Seek pdftops in standard path #endif - if (proc.waitForFinished(15000)) + if (proc.waitForFinished(15000) || proc.state() == QProcess::NotRunning) { res = true; } diff --git a/src/test/ValentinaTest/abstracttest.cpp b/src/test/ValentinaTest/abstracttest.cpp index 351c301a1..a8d4ce5c8 100644 --- a/src/test/ValentinaTest/abstracttest.cpp +++ b/src/test/ValentinaTest/abstracttest.cpp @@ -93,7 +93,7 @@ bool AbstractTest::Run(bool showWarn, int exit, int &exitCode, const QString &pr return false; } - QProcess *process = new QProcess(this); + QScopedPointer process(new QProcess()); process->setWorkingDirectory(info.absoluteDir().absolutePath()); 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); QWARN(qUtf8Printable(msg)); exitCode = TST_EX_TIME_OUT; + process->kill(); return false; } @@ -126,7 +127,6 @@ bool AbstractTest::Run(bool showWarn, int exit, int &exitCode, const QString &pr } exitCode = process->exitCode(); - delete process; return true; }