QProcess: mark obsolete functions as deprecated

QProcess::finished(int)/readChannelMode()/setReadChannelMode() are
obsolete but were not marked as deprecated.
Explicit mark them as deprecated so they can be removed with Qt6.

Change-Id: Iedbfd80a3c987f35caf93181e9277913a18961d9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Christian Ehrlicher 2019-01-17 21:07:35 +01:00
parent 7bebdb472a
commit 5eab68bbee
4 changed files with 25 additions and 12 deletions

View File

@ -813,6 +813,7 @@ void QProcessPrivate::Channel::clear()
\a newState argument is the state QProcess changed to. \a newState argument is the state QProcess changed to.
*/ */
#if QT_DEPRECATED_SINCE(5, 13)
/*! /*!
\fn void QProcess::finished(int exitCode) \fn void QProcess::finished(int exitCode)
\obsolete \obsolete
@ -820,6 +821,7 @@ void QProcessPrivate::Channel::clear()
Use finished(int exitCode, QProcess::ExitStatus status) instead. Use finished(int exitCode, QProcess::ExitStatus status) instead.
*/ */
#endif
/*! /*!
\fn void QProcess::finished(int exitCode, QProcess::ExitStatus exitStatus) \fn void QProcess::finished(int exitCode, QProcess::ExitStatus exitStatus)
@ -1172,7 +1174,9 @@ bool QProcessPrivate::_q_processDied()
//emit q->standardOutputClosed(); //emit q->standardOutputClosed();
//emit q->standardErrorClosed(); //emit q->standardErrorClosed();
#if QT_DEPRECATED_SINCE(5, 13)
emit q->finished(exitCode); emit q->finished(exitCode);
#endif
emit q->finished(exitCode, exitStatus); emit q->finished(exitCode, exitStatus);
} }
#if defined QPROCESS_DEBUG #if defined QPROCESS_DEBUG
@ -1264,6 +1268,7 @@ QProcess::~QProcess()
d->cleanup(); d->cleanup();
} }
#if QT_DEPRECATED_SINCE(5, 13)
/*! /*!
\obsolete \obsolete
Returns the read channel mode of the QProcess. This function is Returns the read channel mode of the QProcess. This function is
@ -1287,6 +1292,7 @@ void QProcess::setReadChannelMode(ProcessChannelMode mode)
{ {
setProcessChannelMode(mode); setProcessChannelMode(mode);
} }
#endif
/*! /*!
\since 4.2 \since 4.2
@ -2473,7 +2479,7 @@ QProcess::ExitStatus QProcess::exitStatus() const
int QProcess::execute(const QString &program, const QStringList &arguments) int QProcess::execute(const QString &program, const QStringList &arguments)
{ {
QProcess process; QProcess process;
process.setReadChannelMode(ForwardedChannels); process.setProcessChannelMode(ForwardedChannels);
process.start(program, arguments); process.start(program, arguments);
if (!process.waitForFinished(-1) || process.error() == FailedToStart) if (!process.waitForFinished(-1) || process.error() == FailedToStart)
return -2; return -2;
@ -2496,7 +2502,7 @@ int QProcess::execute(const QString &program, const QStringList &arguments)
int QProcess::execute(const QString &command) int QProcess::execute(const QString &command)
{ {
QProcess process; QProcess process;
process.setReadChannelMode(ForwardedChannels); process.setProcessChannelMode(ForwardedChannels);
process.start(command); process.start(command);
if (!process.waitForFinished(-1) || process.error() == FailedToStart) if (!process.waitForFinished(-1) || process.error() == FailedToStart)
return -2; return -2;

View File

@ -172,8 +172,12 @@ public:
QStringList arguments() const; QStringList arguments() const;
void setArguments(const QStringList & arguments); void setArguments(const QStringList & arguments);
#if QT_DEPRECATED_SINCE(5, 13)
QT_DEPRECATED_X("Use QProcess::processChannelMode() instead")
ProcessChannelMode readChannelMode() const; ProcessChannelMode readChannelMode() const;
QT_DEPRECATED_X("Use QProcess::setProcessChannelMode() instead")
void setReadChannelMode(ProcessChannelMode mode); void setReadChannelMode(ProcessChannelMode mode);
#endif
ProcessChannelMode processChannelMode() const; ProcessChannelMode processChannelMode() const;
void setProcessChannelMode(ProcessChannelMode mode); void setProcessChannelMode(ProcessChannelMode mode);
InputChannelMode inputChannelMode() const; InputChannelMode inputChannelMode() const;
@ -269,7 +273,10 @@ public Q_SLOTS:
Q_SIGNALS: Q_SIGNALS:
void started(QPrivateSignal); void started(QPrivateSignal);
#if QT_DEPRECATED_SINCE(5, 13)
QT_DEPRECATED_X("Use QProcess::finished(int, QProcess::ExitStatus) instead")
void finished(int exitCode); // ### Qt 6: merge the two signals with a default value void finished(int exitCode); // ### Qt 6: merge the two signals with a default value
#endif
void finished(int exitCode, QProcess::ExitStatus exitStatus); void finished(int exitCode, QProcess::ExitStatus exitStatus);
#if QT_DEPRECATED_SINCE(5,6) #if QT_DEPRECATED_SINCE(5,6)
void error(QProcess::ProcessError error); void error(QProcess::ProcessError error);

View File

@ -185,12 +185,12 @@ void tst_QProcess::getSetCheck()
{ {
QProcess obj1; QProcess obj1;
// ProcessChannelMode QProcess::readChannelMode() // ProcessChannelMode QProcess::readChannelMode()
// void QProcess::setReadChannelMode(ProcessChannelMode) // void QProcess::setProcessChannelMode(ProcessChannelMode)
obj1.setReadChannelMode(QProcess::ProcessChannelMode(QProcess::SeparateChannels)); obj1.setProcessChannelMode(QProcess::ProcessChannelMode(QProcess::SeparateChannels));
QCOMPARE(QProcess::ProcessChannelMode(QProcess::SeparateChannels), obj1.readChannelMode()); QCOMPARE(QProcess::ProcessChannelMode(QProcess::SeparateChannels), obj1.readChannelMode());
obj1.setReadChannelMode(QProcess::ProcessChannelMode(QProcess::MergedChannels)); obj1.setProcessChannelMode(QProcess::ProcessChannelMode(QProcess::MergedChannels));
QCOMPARE(QProcess::ProcessChannelMode(QProcess::MergedChannels), obj1.readChannelMode()); QCOMPARE(QProcess::ProcessChannelMode(QProcess::MergedChannels), obj1.readChannelMode());
obj1.setReadChannelMode(QProcess::ProcessChannelMode(QProcess::ForwardedChannels)); obj1.setProcessChannelMode(QProcess::ProcessChannelMode(QProcess::ForwardedChannels));
QCOMPARE(QProcess::ProcessChannelMode(QProcess::ForwardedChannels), obj1.readChannelMode()); QCOMPARE(QProcess::ProcessChannelMode(QProcess::ForwardedChannels), obj1.readChannelMode());
// ProcessChannel QProcess::readChannel() // ProcessChannel QProcess::readChannel()
@ -913,7 +913,7 @@ public:
switch (n) { switch (n) {
case 0: case 0:
setReadChannelMode(QProcess::MergedChannels); setProcessChannelMode(QProcess::MergedChannels);
connect(this, &QIODevice::readyRead, this, &SoftExitProcess::terminateSlot); connect(this, &QIODevice::readyRead, this, &SoftExitProcess::terminateSlot);
break; break;
case 1: case 1:
@ -929,7 +929,7 @@ public:
this, &SoftExitProcess::terminateSlot); this, &SoftExitProcess::terminateSlot);
break; break;
case 4: case 4:
setReadChannelMode(QProcess::MergedChannels); setProcessChannelMode(QProcess::MergedChannels);
connect(this, SIGNAL(channelReadyRead(int)), this, SLOT(terminateSlot())); connect(this, SIGNAL(channelReadyRead(int)), this, SLOT(terminateSlot()));
break; break;
default: default:
@ -1025,7 +1025,7 @@ void tst_QProcess::softExitInSlots()
void tst_QProcess::mergedChannels() void tst_QProcess::mergedChannels()
{ {
QProcess process; QProcess process;
process.setReadChannelMode(QProcess::MergedChannels); process.setProcessChannelMode(QProcess::MergedChannels);
QCOMPARE(process.readChannelMode(), QProcess::MergedChannels); QCOMPARE(process.readChannelMode(), QProcess::MergedChannels);
process.start("testProcessEcho2/testProcessEcho2"); process.start("testProcessEcho2/testProcessEcho2");
@ -1951,7 +1951,7 @@ void tst_QProcess::setStandardOutputFile()
// run the process // run the process
QProcess process; QProcess process;
process.setReadChannelMode(channelMode); process.setProcessChannelMode(channelMode);
if (channelToTest == QProcess::StandardOutput) if (channelToTest == QProcess::StandardOutput)
process.setStandardOutputFile(file.fileName(), mode); process.setStandardOutputFile(file.fileName(), mode);
else else
@ -2037,7 +2037,7 @@ void tst_QProcess::setStandardOutputProcess()
QFETCH(bool, merged); QFETCH(bool, merged);
QFETCH(bool, waitForBytesWritten); QFETCH(bool, waitForBytesWritten);
source.setReadChannelMode(merged ? QProcess::MergedChannels : QProcess::SeparateChannels); source.setProcessChannelMode(merged ? QProcess::MergedChannels : QProcess::SeparateChannels);
source.setStandardOutputProcess(&sink); source.setStandardOutputProcess(&sink);
source.start("testProcessEcho2/testProcessEcho2"); source.start("testProcessEcho2/testProcessEcho2");

View File

@ -215,7 +215,7 @@ static bool runHelper(const QString &program, const QStringList &arguments, QByt
{ {
#if QT_CONFIG(process) #if QT_CONFIG(process)
QProcess process; QProcess process;
process.setReadChannelMode(QProcess::ForwardedChannels); process.setProcessChannelMode(QProcess::ForwardedChannels);
process.start(program, arguments); process.start(program, arguments);
if (!process.waitForStarted()) { if (!process.waitForStarted()) {
*errorMessage = "Unable to start '" + program.toLocal8Bit() + " ': " *errorMessage = "Unable to start '" + program.toLocal8Bit() + " ': "