summaryrefslogtreecommitdiff
path: root/src/plugins/android/androidmanager.cpp
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@qt.io>2016-04-29 16:52:58 +0200
committerTobias Hunger <tobias.hunger@qt.io>2016-05-11 10:04:38 +0000
commitddefe062c73e35def585f8fc6c90a4f18e47c0f4 (patch)
tree03c3aecc501c03b92e259fe0ae1c4d472033b7e5 /src/plugins/android/androidmanager.cpp
parent1a248b1b932e2c7c42e25993d921e78c52aa4bcf (diff)
downloadqt-creator-ddefe062c73e35def585f8fc6c90a4f18e47c0f4.tar.gz
Fix up QProcess::waitForFinished()
waitForFinish returns false if the process is no longer running at the time of the call. Handle that throughout the codebase. Change-Id: Ia7194095454e82efbd4eb88f2d55926bdd09e094 Reviewed-by: hjk <hjk@theqtcompany.com>
Diffstat (limited to 'src/plugins/android/androidmanager.cpp')
-rw-r--r--src/plugins/android/androidmanager.cpp36
1 files changed, 13 insertions, 23 deletions
diff --git a/src/plugins/android/androidmanager.cpp b/src/plugins/android/androidmanager.cpp
index d35a1998e3..a8a778cd39 100644
--- a/src/plugins/android/androidmanager.cpp
+++ b/src/plugins/android/androidmanager.cpp
@@ -51,6 +51,7 @@
#include <qtsupport/qtkitinformation.h>
#include <qtsupport/qtsupportconstants.h>
#include <utils/algorithm.h>
+#include <utils/synchronousprocess.h>
#include <QDir>
#include <QFileSystemWatcher>
@@ -345,13 +346,13 @@ void AndroidManager::installQASIPackage(ProjectExplorer::Target *target, const Q
QStringList arguments = AndroidDeviceInfo::adbSelector(deviceSerialNumber);
arguments << QLatin1String("install") << QLatin1String("-r ") << packagePath;
- process->connect(process, SIGNAL(finished(int)), process, SLOT(deleteLater()));
+ connect(process, static_cast<void (QProcess::*)(int)>(&QProcess::finished),
+ process, &QObject::deleteLater);
const QString adb = AndroidConfigurations::currentConfig().adbToolPath().toString();
Core::MessageManager::write(adb + QLatin1Char(' ') + arguments.join(QLatin1Char(' ')));
process->start(adb, arguments);
- if (!process->waitForFinished(500))
+ if (!process->waitForStarted(500) && process->state() != QProcess::Running)
delete process;
-
}
bool AndroidManager::checkKeystorePassword(const QString &keystorePath, const QString &keystorePasswd)
@@ -364,16 +365,10 @@ bool AndroidManager::checkKeystorePassword(const QString &keystorePath, const QS
<< keystorePath
<< QLatin1String("--storepass")
<< keystorePasswd;
- QProcess proc;
- proc.start(AndroidConfigurations::currentConfig().keytoolPath().toString(), arguments);
- if (!proc.waitForStarted(10000))
- return false;
- if (!proc.waitForFinished(10000)) {
- proc.kill();
- proc.waitForFinished();
- return false;
- }
- return proc.exitCode() == 0;
+ Utils::SynchronousProcess proc;
+ proc.setTimeoutS(10);
+ Utils::SynchronousProcessResponse response = proc.run(AndroidConfigurations::currentConfig().keytoolPath().toString(), arguments);
+ return (response.result == Utils::SynchronousProcessResponse::Finished && response.exitCode == 0);
}
bool AndroidManager::checkCertificatePassword(const QString &keystorePath, const QString &keystorePasswd, const QString &alias, const QString &certificatePasswd)
@@ -393,16 +388,11 @@ bool AndroidManager::checkCertificatePassword(const QString &keystorePath, const
else
arguments << certificatePasswd;
- QProcess proc;
- proc.start(AndroidConfigurations::currentConfig().keytoolPath().toString(), arguments);
- if (!proc.waitForStarted(10000))
- return false;
- if (!proc.waitForFinished(10000)) {
- proc.kill();
- proc.waitForFinished();
- return false;
- }
- return proc.exitCode() == 0;
+ Utils::SynchronousProcess proc;
+ proc.setTimeoutS(10);
+ Utils::SynchronousProcessResponse response
+ = proc.run(AndroidConfigurations::currentConfig().keytoolPath().toString(), arguments);
+ return response.result == Utils::SynchronousProcessResponse::Finished && response.exitCode == 0;
}
bool AndroidManager::checkForQt51Files(Utils::FileName fileName)