Doc: fix misleading documentation of QProcess::set[Process]Environment
The example suggested that QProcess searches the PATH variable to find the executable for the child process. That's not true. The environment that's passed with setProcessEnvironment is just passed to the child process. Removed the misleading example and fixed the function's description. Task-number: QTBUG-7321 Change-Id: I8ac4b6b02002eb0a99686f09bcf45f9bc677c8e2 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@digia.com>
This commit is contained in:
parent
0175ad4d3f
commit
377ef06aef
@ -47,7 +47,6 @@ void startProcess()
|
|||||||
QProcess process;
|
QProcess process;
|
||||||
QStringList env = QProcess::systemEnvironment();
|
QStringList env = QProcess::systemEnvironment();
|
||||||
env << "TMPDIR=C:\\MyApp\\temp"; // Add an environment variable
|
env << "TMPDIR=C:\\MyApp\\temp"; // Add an environment variable
|
||||||
env.replaceInStrings(QRegExp("^PATH=(.*)", Qt::CaseInsensitive), "PATH=\\1;C:\\Bin");
|
|
||||||
process.setEnvironment(env);
|
process.setEnvironment(env);
|
||||||
process.start("myapp");
|
process.start("myapp");
|
||||||
//! [0]
|
//! [0]
|
||||||
@ -58,7 +57,6 @@ process.start("myapp");
|
|||||||
QProcess process;
|
QProcess process;
|
||||||
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
||||||
env.insert("TMPDIR", "C:\\MyApp\\temp"); // Add an environment variable
|
env.insert("TMPDIR", "C:\\MyApp\\temp"); // Add an environment variable
|
||||||
env.insert("PATH", env.value("Path") + ";C:\\Bin");
|
|
||||||
process.setProcessEnvironment(env);
|
process.setProcessEnvironment(env);
|
||||||
process.start("myapp");
|
process.start("myapp");
|
||||||
//! [1]
|
//! [1]
|
||||||
|
@ -1659,11 +1659,10 @@ QProcess::ProcessState QProcess::state() const
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
\deprecated
|
\deprecated
|
||||||
Sets the environment that QProcess will use when starting a process to the
|
Sets the environment that QProcess will pass to the child process.
|
||||||
\a environment specified which consists of a list of key=value pairs.
|
The parameter \a environment is a list of key=value pairs.
|
||||||
|
|
||||||
For example, the following code adds the \c{C:\\BIN} directory to the list of
|
For example, the following code adds the environment variable \c{TMPDIR}:
|
||||||
executable paths (\c{PATHS}) on Windows:
|
|
||||||
|
|
||||||
\snippet qprocess-environment/main.cpp 0
|
\snippet qprocess-environment/main.cpp 0
|
||||||
|
|
||||||
@ -1679,7 +1678,7 @@ void QProcess::setEnvironment(const QStringList &environment)
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
\deprecated
|
\deprecated
|
||||||
Returns the environment that QProcess will use when starting a
|
Returns the environment that QProcess will pass to its child
|
||||||
process, or an empty QStringList if no environment has been set
|
process, or an empty QStringList if no environment has been set
|
||||||
using setEnvironment(). If no environment has been set, the
|
using setEnvironment(). If no environment has been set, the
|
||||||
environment of the calling process will be used.
|
environment of the calling process will be used.
|
||||||
@ -1697,11 +1696,9 @@ QStringList QProcess::environment() const
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
\since 4.6
|
\since 4.6
|
||||||
Sets the environment that QProcess will use when starting a process to the
|
Sets the \a environment that QProcess will pass to the child process.
|
||||||
\a environment object.
|
|
||||||
|
|
||||||
For example, the following code adds the \c{C:\\BIN} directory to the list of
|
For example, the following code adds the environment variable \c{TMPDIR}:
|
||||||
executable paths (\c{PATHS}) on Windows and sets \c{TMPDIR}:
|
|
||||||
|
|
||||||
\snippet qprocess-environment/main.cpp 1
|
\snippet qprocess-environment/main.cpp 1
|
||||||
|
|
||||||
@ -1717,7 +1714,7 @@ void QProcess::setProcessEnvironment(const QProcessEnvironment &environment)
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
\since 4.6
|
\since 4.6
|
||||||
Returns the environment that QProcess will use when starting a
|
Returns the environment that QProcess will pass to its child
|
||||||
process, or an empty object if no environment has been set using
|
process, or an empty object if no environment has been set using
|
||||||
setEnvironment() or setProcessEnvironment(). If no environment has
|
setEnvironment() or setProcessEnvironment(). If no environment has
|
||||||
been set, the environment of the calling process will be used.
|
been set, the environment of the calling process will be used.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user