forked from qt-creator/qt-creator
QtcProcess: Add processChannelMode() getter
Use ProcessInterface's setup data when handling readyRead signals. In this way the user may still change this setting, also when QtcProcess is running, as a preparation for the next run. In this way this works like all other QtcProcess mutators. Change-Id: Ie80475e322162ce109fb95468ce858f9c98eefa9 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -35,6 +35,8 @@
|
|||||||
|
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
|
|
||||||
|
namespace Internal { class QtcProcessPrivate; }
|
||||||
|
|
||||||
class QTCREATOR_UTILS_EXPORT ProcessSetupData
|
class QTCREATOR_UTILS_EXPORT ProcessSetupData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -121,6 +123,7 @@ private:
|
|||||||
virtual bool waitForFinished(int msecs) = 0;
|
virtual bool waitForFinished(int msecs) = 0;
|
||||||
|
|
||||||
friend class QtcProcess;
|
friend class QtcProcess;
|
||||||
|
friend class Internal::QtcProcessPrivate;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Utils
|
} // namespace Utils
|
||||||
|
@@ -1142,9 +1142,13 @@ qint64 QtcProcess::applicationMainThreadId() const
|
|||||||
return d->m_applicationMainThreadId;
|
return d->m_applicationMainThreadId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QProcess::ProcessChannelMode QtcProcess::processChannelMode() const
|
||||||
|
{
|
||||||
|
return d->m_setup.m_processChannelMode;
|
||||||
|
}
|
||||||
|
|
||||||
void QtcProcess::setProcessChannelMode(QProcess::ProcessChannelMode mode)
|
void QtcProcess::setProcessChannelMode(QProcess::ProcessChannelMode mode)
|
||||||
{
|
{
|
||||||
QTC_CHECK(state() == QProcess::NotRunning);
|
|
||||||
d->m_setup.m_processChannelMode = mode;
|
d->m_setup.m_processChannelMode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1569,16 +1573,16 @@ void QtcProcessPrivate::handleReadyRead(const QByteArray &outputData, const QByt
|
|||||||
m_hangTimerCount = 0;
|
m_hangTimerCount = 0;
|
||||||
// TODO: store a copy of m_processChannelMode on start()? Currently we assert that state
|
// TODO: store a copy of m_processChannelMode on start()? Currently we assert that state
|
||||||
// is NotRunning when setting the process channel mode.
|
// is NotRunning when setting the process channel mode.
|
||||||
if (m_setup.m_processChannelMode == QProcess::ForwardedOutputChannel
|
if (m_process->m_setup.m_processChannelMode == QProcess::ForwardedOutputChannel
|
||||||
|| m_setup.m_processChannelMode == QProcess::ForwardedChannels) {
|
|| m_process->m_setup.m_processChannelMode == QProcess::ForwardedChannels) {
|
||||||
std::cout << outputData.constData() << std::flush;
|
std::cout << outputData.constData() << std::flush;
|
||||||
} else {
|
} else {
|
||||||
m_stdOut.append(outputData);
|
m_stdOut.append(outputData);
|
||||||
if (!outputData.isEmpty())
|
if (!outputData.isEmpty())
|
||||||
emitReadyReadStandardOutput();
|
emitReadyReadStandardOutput();
|
||||||
}
|
}
|
||||||
if (m_setup.m_processChannelMode == QProcess::ForwardedErrorChannel
|
if (m_process->m_setup.m_processChannelMode == QProcess::ForwardedErrorChannel
|
||||||
|| m_setup.m_processChannelMode == QProcess::ForwardedChannels) {
|
|| m_process->m_setup.m_processChannelMode == QProcess::ForwardedChannels) {
|
||||||
std::cerr << errorData.constData() << std::flush;
|
std::cerr << errorData.constData() << std::flush;
|
||||||
} else {
|
} else {
|
||||||
m_stdErr.append(errorData);
|
m_stdErr.append(errorData);
|
||||||
|
@@ -121,6 +121,7 @@ public:
|
|||||||
bool isRunAsRoot() const;
|
bool isRunAsRoot() const;
|
||||||
void setAbortOnMetaChars(bool abort);
|
void setAbortOnMetaChars(bool abort);
|
||||||
|
|
||||||
|
QProcess::ProcessChannelMode processChannelMode() const;
|
||||||
void setProcessChannelMode(QProcess::ProcessChannelMode mode);
|
void setProcessChannelMode(QProcess::ProcessChannelMode mode);
|
||||||
void setStandardInputFile(const QString &inputFile);
|
void setStandardInputFile(const QString &inputFile);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user