diff options
author | Jake Petroules <jake.petroules@petroules.com> | 2015-03-20 22:17:11 -0700 |
---|---|---|
committer | Jake Petroules <jake.petroules@petroules.com> | 2015-03-27 04:08:47 +0000 |
commit | cd0c7c663bff25d49ce64614242645edd7b43c6b (patch) | |
tree | 431f4837a85e657d0ec8a106413ed25ce60d67a2 /src/lib/corelib/api/runenvironment.cpp | |
parent | c96ef7654f6ea8ebd5737261aada123b52981213 (diff) |
Try to forward "bad interpreter" errors to the user.
Change-Id: If287b7480be854f4bae055ed9d575f16fd6f54df
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Diffstat (limited to 'src/lib/corelib/api/runenvironment.cpp')
-rw-r--r-- | src/lib/corelib/api/runenvironment.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/lib/corelib/api/runenvironment.cpp b/src/lib/corelib/api/runenvironment.cpp index 147306d52..59430ce34 100644 --- a/src/lib/corelib/api/runenvironment.cpp +++ b/src/lib/corelib/api/runenvironment.cpp @@ -41,6 +41,7 @@ #include <tools/installoptions.h> #include <tools/preferences.h> #include <tools/propertyfinder.h> +#include <tools/shellutils.h> #include <QDir> #include <QProcess> @@ -201,7 +202,27 @@ int RunEnvironment::runTarget(const QString &targetBin, const QStringList &argum process.setProcessEnvironment(d->resolvedProduct->runEnvironment); process.setProcessChannelMode(QProcess::ForwardedChannels); process.start(targetExecutable, targetArguments); - process.waitForFinished(-1); + if (!process.waitForFinished(-1)) { + if (process.error() == QProcess::FailedToStart) { + QString errorPrefixString; +#ifdef Q_OS_UNIX + if (QFileInfo(targetExecutable).isExecutable()) { + const QString interpreter(shellInterpreter(targetExecutable)); + if (!interpreter.isEmpty()) { + errorPrefixString = Tr::tr("%1: bad interpreter: ").arg(interpreter); + } + } +#endif + throw ErrorInfo(Tr::tr("The process '%1' could not be started: %2") + .arg(targetExecutable) + .arg(errorPrefixString + process.errorString())); + } else { + d->logger.qbsWarning() + << "QProcess error: " << process.errorString(); + } + + return EXIT_FAILURE; + } return process.exitCode(); } |