From 06b1759e694f57056454506ed10b14eb2639d07c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 25 Nov 2008 19:48:22 +0100 Subject: Add the reason for a process's failure to start to the errorString It would have been of great help to find this out when I was debugging the previous commit. --- src/corelib/io/qprocess_win.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp index 50a4a00..8ece6ec 100644 --- a/src/corelib/io/qprocess_win.cpp +++ b/src/corelib/io/qprocess_win.cpp @@ -398,6 +398,10 @@ void QProcessPrivate::startProcess() environment.isEmpty() ? 0 : envlist.data(), workingDirectory.isEmpty() ? 0 : (wchar_t*)QDir::toNativeSeparators(workingDirectory).utf16(), &startupInfo, pid); + if (!success) { + // Capture the error string before we do CloseHandle below + q->setErrorString(QProcess::tr("Process failed to start: %1").arg(qt_error_string())); + } if (stdinChannel.pipe[0] != INVALID_Q_PIPE) { CloseHandle(stdinChannel.pipe[0]); @@ -416,7 +420,6 @@ void QProcessPrivate::startProcess() if (!success) { cleanup(); processError = QProcess::FailedToStart; - q->setErrorString(QProcess::tr("Process failed to start")); emit q->error(processError); q->setProcessState(QProcess::NotRunning); return; -- cgit v0.12