summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2020-05-13 16:50:59 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2020-05-27 11:55:06 +0200
commitee92ee7a3cf7ef6017a2950a590005abfd37cf1a (patch)
tree6b3dc1b659e15f494b84f066311b545187a5478c /src/corelib
parent3373aa8b351691d395cd15c634ca1b60fd688c6a (diff)
Remove deprecated QProcess methods
Add default parameter for arguments in start, startDetached, and execute for better source compatibility with Qt 5.15. This has the risk of then hiding incorrect calls to the previous overload taking a single "command" strings if code is ported from pre-5.15 or ignores deprecation warnings. This is acceptable, given that the alternative is that all calls to these functions would require a default constructed QStringList as the second parameter. Change-Id: I1ba4df97ac4894d007da5083c8359015d784ddbb Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/io/qprocess.cpp153
-rw-r--r--src/corelib/io/qprocess.h37
2 files changed, 3 insertions, 187 deletions
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 7182eb2a26..374142702b 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -107,21 +107,6 @@ QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
/*!
- \since 5.6
-
- \macro QT_NO_PROCESS_COMBINED_ARGUMENT_START
- \relates QProcess
-
- Disables the
- \l {QProcess::start(const QString &, QIODevice::OpenMode)}
- {QProcess::start}() overload taking a single string.
- In most cases where it is used, the user intends for the first argument
- to be treated atomically as per the other overload.
-
- \sa QProcess::start(const QString &command, QIODevice::OpenMode mode)
-*/
-
-/*!
\class QProcessEnvironment
\inmodule QtCore
@@ -984,12 +969,6 @@ void QProcessPrivate::setErrorAndEmit(QProcess::ProcessError error, const QStrin
Q_ASSERT(error != QProcess::UnknownError);
setError(error, description);
emit q->errorOccurred(processError);
-#if QT_DEPRECATED_SINCE(5, 6)
-QT_WARNING_PUSH
-QT_WARNING_DISABLE_DEPRECATED
- emit q->error(processError);
-QT_WARNING_POP
-#endif
}
/*!
@@ -1256,32 +1235,6 @@ QProcess::~QProcess()
d->cleanup();
}
-#if QT_DEPRECATED_SINCE(5, 13)
-/*!
- \obsolete
- Returns the read channel mode of the QProcess. This function is
- equivalent to processChannelMode()
-
- \sa processChannelMode()
-*/
-QProcess::ProcessChannelMode QProcess::readChannelMode() const
-{
- return processChannelMode();
-}
-
-/*!
- \obsolete
-
- Use setProcessChannelMode(\a mode) instead.
-
- \sa setProcessChannelMode()
-*/
-void QProcess::setReadChannelMode(ProcessChannelMode mode)
-{
- setProcessChannelMode(mode);
-}
-#endif
-
/*!
\since 4.2
@@ -2252,63 +2205,6 @@ QStringList QProcess::splitCommand(QStringView command)
}
/*!
- \obsolete
- \overload
-
- Starts the command \a command in a new process.
- The OpenMode is set to \a mode.
-
- \a command is a single string of text containing both the program name
- and its arguments. The arguments are separated by one or more spaces.
- For example:
-
- \snippet code/src_corelib_io_qprocess.cpp 5
-
- Arguments containing spaces must be quoted to be correctly supplied to
- the new process. For example:
-
- \snippet code/src_corelib_io_qprocess.cpp 6
-
- Literal quotes in the \a command string are represented by triple quotes.
- For example:
-
- \snippet code/src_corelib_io_qprocess.cpp 7
-
- After the \a command string has been split and unquoted, this function
- behaves like the overload which takes the arguments as a string list.
-
- You can disable this overload by defining \c
- QT_NO_PROCESS_COMBINED_ARGUMENT_START when you compile your applications.
- This can be useful if you want to ensure that you are not splitting arguments
- unintentionally, for example. In virtually all cases, using the other overload
- is the preferred method.
-
- On operating systems where the system API for passing command line
- arguments to a subprocess natively uses a single string (Windows), one can
- conceive command lines which cannot be passed via QProcess's portable
- list-based API. In these rare cases you need to use setProgram() and
- setNativeArguments() instead of this function.
-
- \sa splitCommand()
-
-*/
-#if !defined(QT_NO_PROCESS_COMBINED_ARGUMENT_START)
-void QProcess::start(const QString &command, OpenMode mode)
-{
- QStringList args = splitCommand(command);
- if (args.isEmpty()) {
- Q_D(QProcess);
- d->setErrorAndEmit(QProcess::FailedToStart, tr("No program defined"));
- return;
- }
-
- const QString prog = args.takeFirst();
-
- start(prog, args, mode);
-}
-#endif
-
-/*!
\since 5.0
Returns the program the process was last started with.
@@ -2460,29 +2356,6 @@ int QProcess::execute(const QString &program, const QStringList &arguments)
}
/*!
- \obsolete
- \overload
-
- Starts the program \a command in a new process, waits for it to finish,
- and then returns the exit code.
-
- Argument handling is identical to the respective start() overload.
-
- After the \a command string has been split and unquoted, this function
- behaves like the overload which takes the arguments as a string list.
-
- \sa start(), splitCommand()
-*/
-int QProcess::execute(const QString &command)
-{
- QStringList args = splitCommand(command);
- if (args.isEmpty())
- return -2;
- QString program = args.takeFirst();
- return execute(program, args);
-}
-
-/*!
\overload startDetached()
Starts the program \a program with the arguments \a arguments in a
@@ -2513,32 +2386,6 @@ bool QProcess::startDetached(const QString &program,
return process.startDetached(pid);
}
-/*!
- \obsolete
- \overload startDetached()
-
- Starts the command \a command in a new process, and detaches from it.
- Returns \c true on success; otherwise returns \c false.
-
- Argument handling is identical to the respective start() overload.
-
- After the \a command string has been split and unquoted, this function
- behaves like the overload which takes the arguments as a string list.
-
- \sa start(const QString &command, QIODevice::OpenMode mode), splitCommand()
-*/
-bool QProcess::startDetached(const QString &command)
-{
- QStringList args = splitCommand(command);
- if (args.isEmpty())
- return false;
-
- QProcess process;
- process.setProgram(args.takeFirst());
- process.setArguments(args);
- return process.startDetached();
-}
-
QT_BEGIN_INCLUDE_NAMESPACE
#if defined(Q_OS_MACX)
# include <crt_externs.h>
diff --git a/src/corelib/io/qprocess.h b/src/corelib/io/qprocess.h
index ee83c93cf8..f43dfad840 100644
--- a/src/corelib/io/qprocess.h
+++ b/src/corelib/io/qprocess.h
@@ -158,16 +158,7 @@ public:
explicit QProcess(QObject *parent = nullptr);
virtual ~QProcess();
- void start(const QString &program, const QStringList &arguments, OpenMode mode = ReadWrite);
-#if !defined(QT_NO_PROCESS_COMBINED_ARGUMENT_START)
-#if QT_DEPRECATED_SINCE(5, 15)
- QT_DEPRECATED_X(
- "Use QProcess::start(const QString &program, const QStringList &arguments,"
- "OpenMode mode = ReadWrite) instead"
- )
- void start(const QString &command, OpenMode mode = ReadWrite);
-#endif
-#endif
+ void start(const QString &program, const QStringList &arguments = {}, OpenMode mode = ReadWrite);
void start(OpenMode mode = ReadWrite);
bool startDetached(qint64 *pid = nullptr);
bool open(OpenMode mode = ReadWrite) override;
@@ -178,12 +169,6 @@ public:
QStringList arguments() const;
void setArguments(const QStringList & arguments);
-#if QT_DEPRECATED_SINCE(5, 13)
- QT_DEPRECATED_X("Use QProcess::processChannelMode() instead")
- ProcessChannelMode readChannelMode() const;
- QT_DEPRECATED_X("Use QProcess::setProcessChannelMode() instead")
- void setReadChannelMode(ProcessChannelMode mode);
-#endif
ProcessChannelMode processChannelMode() const;
void setProcessChannelMode(ProcessChannelMode mode);
InputChannelMode inputChannelMode() const;
@@ -252,21 +237,9 @@ public:
bool isSequential() const override;
void close() override;
- static int execute(const QString &program, const QStringList &arguments);
-#if QT_DEPRECATED_SINCE(5, 15)
- QT_DEPRECATED_X(
- "Use QProcess::execute(const QString &program, const QStringList &arguments) instead"
- )
- static int execute(const QString &command);
-#endif
- static bool startDetached(const QString &program, const QStringList &arguments,
+ static int execute(const QString &program, const QStringList &arguments = {});
+ static bool startDetached(const QString &program, const QStringList &arguments = {},
const QString &workingDirectory = QString(), qint64 *pid = nullptr);
-#if QT_DEPRECATED_SINCE(5, 15)
- QT_DEPRECATED_X(
- "Use QProcess::startDetached(const QString &program, const QStringList &arguments) instead"
- )
- static bool startDetached(const QString &command);
-#endif
static QStringList systemEnvironment();
@@ -281,10 +254,6 @@ public Q_SLOTS:
Q_SIGNALS:
void started(QPrivateSignal);
void finished(int exitCode, QProcess::ExitStatus exitStatus = NormalExit);
-#if QT_DEPRECATED_SINCE(5, 6)
- QT_DEPRECATED_X("Use QProcess::errorOccurred(QProcess::ProcessError) instead")
- void error(QProcess::ProcessError error);
-#endif
void errorOccurred(QProcess::ProcessError error);
void stateChanged(QProcess::ProcessState state, QPrivateSignal);