summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@theqtcompany.com>2015-11-09 12:53:54 +0100
committerKai Koehne <kai.koehne@theqtcompany.com>2015-11-12 14:17:40 +0000
commit351853e04d585cc7e9098140fb50920d99597629 (patch)
tree053ce81a7375d9912bfc9f1d154b65b66bd08fd2 /src/corelib
parent4890c75d0d301fcfea594a5ad80577d0ffa6bb88 (diff)
Do not overwrite detailed error message if process fails to launch
On Unix we get a detailed error message when a process fails to start, but later on we overwrite it with a generic "Process fails to start". Fix this by keeping the original error message (if one is available). This fixes a regression introduced in commit 5147f73ac3. Task-number: QTBUG-49286 Change-Id: Idd0f0fed9773d39f2947fc3e532b51e670952caf Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/io/qprocess.cpp5
-rw-r--r--src/corelib/io/qprocess_p.h2
-rw-r--r--src/corelib/io/qprocess_unix.cpp6
-rw-r--r--src/corelib/io/qprocess_win.cpp2
-rw-r--r--src/corelib/io/qprocess_wince.cpp2
5 files changed, 9 insertions, 8 deletions
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 8fbe96adb9..b09c99985c 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -1179,14 +1179,15 @@ bool QProcessPrivate::_q_startupNotification()
if (startupSocketNotifier)
startupSocketNotifier->setEnabled(false);
- if (processStarted()) {
+ QString errorMessage;
+ if (processStarted(&errorMessage)) {
q->setProcessState(QProcess::Running);
emit q->started(QProcess::QPrivateSignal());
return true;
}
q->setProcessState(QProcess::NotRunning);
- setErrorAndEmit(QProcess::FailedToStart);
+ setErrorAndEmit(QProcess::FailedToStart, errorMessage);
#ifdef Q_OS_UNIX
// make sure the process manager removes this entry
waitForDeadChild();
diff --git a/src/corelib/io/qprocess_p.h b/src/corelib/io/qprocess_p.h
index fc6b5345d1..d3f251c399 100644
--- a/src/corelib/io/qprocess_p.h
+++ b/src/corelib/io/qprocess_p.h
@@ -352,7 +352,7 @@ public:
#elif defined(QPROCESS_USE_SPAWN)
pid_t spawnChild(pid_t *ppid, const char *workingDirectory, char **argv, char **envp);
#endif
- bool processStarted();
+ bool processStarted(QString *errorMessage = Q_NULLPTR);
void terminateProcess();
void killProcess();
void findExitCode();
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index 63480dfc6b..a5488f48cc 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -714,7 +714,7 @@ report_errno:
}
#endif
-bool QProcessPrivate::processStarted()
+bool QProcessPrivate::processStarted(QString *errorMessage)
{
ushort buf[errorBufferMax];
int i = qt_safe_read(childStartedPipe[0], &buf, sizeof buf);
@@ -731,8 +731,8 @@ bool QProcessPrivate::processStarted()
#endif
// did we read an error message?
- if (i > 0)
- q_func()->setErrorString(QString((const QChar *)buf, i / sizeof(QChar)));
+ if ((i > 0) && errorMessage)
+ *errorMessage = QString((const QChar *)buf, i / sizeof(QChar));
return i <= 0;
}
diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp
index e77249975c..80e6d5bb61 100644
--- a/src/corelib/io/qprocess_win.cpp
+++ b/src/corelib/io/qprocess_win.cpp
@@ -543,7 +543,7 @@ void QProcessPrivate::startProcess()
_q_startupNotification();
}
-bool QProcessPrivate::processStarted()
+bool QProcessPrivate::processStarted(QString * /*errorMessage*/)
{
return processState == QProcess::Running;
}
diff --git a/src/corelib/io/qprocess_wince.cpp b/src/corelib/io/qprocess_wince.cpp
index 807472b7b2..9b63ece15c 100644
--- a/src/corelib/io/qprocess_wince.cpp
+++ b/src/corelib/io/qprocess_wince.cpp
@@ -160,7 +160,7 @@ void QProcessPrivate::startProcess()
_q_startupNotification();
}
-bool QProcessPrivate::processStarted()
+bool QProcessPrivate::processStarted(QString * /*errorMessage*/)
{
return processState == QProcess::Running;
}