summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qprocess.cpp58
-rw-r--r--src/corelib/io/qprocess.h5
-rw-r--r--src/corelib/io/qprocess_p.h3
-rw-r--r--src/corelib/io/qprocess_symbian.cpp17
-rw-r--r--src/corelib/io/qprocess_win.cpp5
5 files changed, 77 insertions, 11 deletions
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 8eba2b0..9bc4063 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -1377,6 +1377,50 @@ void QProcess::setStandardOutputProcess(QProcess *destination)
dto->stdinChannel.pipeFrom(dfrom);
}
+#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
+
+/*!
+ \since 4.7
+
+ Returns the additional native command line arguments for the program.
+
+ \note This function is available only on the Windows and Symbian
+ platforms.
+
+ \sa setNativeArguments()
+*/
+QString QProcess::nativeArguments() const
+{
+ Q_D(const QProcess);
+ return d->nativeArguments;
+}
+
+/*!
+ \since 4.7
+ \overload
+
+ Sets additional native command line arguments for the program.
+
+ On operating systems where the system API for passing command line
+ arguments to a subprocess natively uses a single string, one can
+ conceive command lines which cannot be passed via QProcess's portable
+ list-based API. In such cases this function must be used to set a
+ string which is \e appended to the string composed from the usual
+ argument list, with a delimiting space.
+
+ \note This function is available only on the Windows and Symbian
+ platforms.
+
+ \sa nativeArguments()
+*/
+void QProcess::setNativeArguments(const QString &arguments)
+{
+ Q_D(QProcess);
+ d->nativeArguments = arguments;
+}
+
+#endif
+
/*!
If QProcess has been assigned a working directory, this function returns
the working directory that the QProcess will enter before the program has
@@ -2082,14 +2126,19 @@ QProcess::ExitStatus QProcess::exitStatus() const
process.
On Windows, arguments that contain spaces are wrapped in quotes.
+
+ If the process cannot be started, -2 is returned. If the process
+ crashes, -1 is returned. Otherwise, the process' exit code is
+ returned.
*/
int QProcess::execute(const QString &program, const QStringList &arguments)
{
QProcess process;
process.setReadChannelMode(ForwardedChannels);
process.start(program, arguments);
- process.waitForFinished(-1);
- return process.exitCode();
+ if (!process.waitForFinished(-1))
+ return -2;
+ return process.exitStatus() == QProcess::NormalExit ? process.exitCode() : -1;
}
/*!
@@ -2104,8 +2153,9 @@ int QProcess::execute(const QString &program)
QProcess process;
process.setReadChannelMode(ForwardedChannels);
process.start(program);
- process.waitForFinished(-1);
- return process.exitCode();
+ if (!process.waitForFinished(-1))
+ return -2;
+ return process.exitStatus() == QProcess::NormalExit ? process.exitCode() : -1;
}
/*!
diff --git a/src/corelib/io/qprocess.h b/src/corelib/io/qprocess.h
index f84b855..b07d742 100644
--- a/src/corelib/io/qprocess.h
+++ b/src/corelib/io/qprocess.h
@@ -148,6 +148,11 @@ public:
void setStandardErrorFile(const QString &fileName, OpenMode mode = Truncate);
void setStandardOutputProcess(QProcess *destination);
+#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
+ QString nativeArguments() const;
+ void setNativeArguments(const QString &arguments);
+#endif
+
QString workingDirectory() const;
void setWorkingDirectory(const QString &dir);
diff --git a/src/corelib/io/qprocess_p.h b/src/corelib/io/qprocess_p.h
index 60b7b5a..8b7e3ff 100644
--- a/src/corelib/io/qprocess_p.h
+++ b/src/corelib/io/qprocess_p.h
@@ -181,6 +181,9 @@ public:
QString program;
QStringList arguments;
+#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
+ QString nativeArguments;
+#endif
QProcessEnvironment environment;
QRingBuffer outputReadBuffer;
diff --git a/src/corelib/io/qprocess_symbian.cpp b/src/corelib/io/qprocess_symbian.cpp
index 92212fe..af657b2 100644
--- a/src/corelib/io/qprocess_symbian.cpp
+++ b/src/corelib/io/qprocess_symbian.cpp
@@ -219,7 +219,8 @@ static bool qt_rprocess_running(RProcess *proc)
return false;
}
-static void qt_create_symbian_commandline(const QStringList &arguments, QString &commandLine)
+static void qt_create_symbian_commandline(
+ const QStringList &arguments, const QString &nativeArguments, QString &commandLine)
{
for (int i = 0; i < arguments.size(); ++i) {
QString tmp = arguments.at(i);
@@ -243,12 +244,14 @@ static void qt_create_symbian_commandline(const QStringList &arguments, QString
}
}
- // Chop the extra trailing space if any arguments were appended
- if (arguments.size())
+ if (!nativeArguments.isEmpty())
+ commandLine += nativeArguments;
+ else if (!commandLine.isEmpty()) // Chop the extra trailing space if any arguments were appended
commandLine.chop(1);
}
-static TInt qt_create_symbian_process(RProcess **proc, const QString &programName, const QStringList &arguments)
+static TInt qt_create_symbian_process(RProcess **proc,
+ const QString &programName, const QStringList &arguments, const QString &nativeArguments)
{
RProcess *newProc = NULL;
newProc = new RProcess();
@@ -257,7 +260,7 @@ static TInt qt_create_symbian_process(RProcess **proc, const QString &programNam
return KErrNoMemory;
QString commandLine;
- qt_create_symbian_commandline(arguments, commandLine);
+ qt_create_symbian_commandline(arguments, nativeArguments, commandLine);
TPtrC program_ptr(reinterpret_cast<const TText*>(programName.constData()));
TPtrC cmdline_ptr(reinterpret_cast<const TText*>(commandLine.constData()));
@@ -794,7 +797,7 @@ void QProcessPrivate::startProcess()
q, SLOT(_q_processDied()));
}
- TInt err = qt_create_symbian_process(&symbianProcess, program, arguments);
+ TInt err = qt_create_symbian_process(&symbianProcess, program, arguments, nativeArguments);
if (err == KErrNone) {
pid = symbianProcess->Id().Id();
@@ -1030,7 +1033,7 @@ bool QProcessPrivate::startDetached(const QString &program, const QStringList &a
RProcess *newProc = NULL;
- TInt err = qt_create_symbian_process(&newProc, program, arguments);
+ TInt err = qt_create_symbian_process(&newProc, program, arguments, QString());
if (err == KErrNone) {
if (pid)
diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp
index cb25a58..702349f 100644
--- a/src/corelib/io/qprocess_win.cpp
+++ b/src/corelib/io/qprocess_win.cpp
@@ -366,6 +366,11 @@ void QProcessPrivate::startProcess()
if (environment.d.constData())
envlist = qt_create_environment(environment.d.constData()->hash);
#endif
+ if (!nativeArguments.isEmpty()) {
+ if (!args.isEmpty())
+ args += QLatin1Char(' ');
+ args += nativeArguments;
+ }
#if defined QPROCESS_DEBUG
qDebug("Creating process");