forked from qt-creator/qt-creator
Utils: Use a setter for QtcProcess::run(.... writeData)
Change-Id: Ic56f8ecc158374251f89bb62c4b3d62168ae8409 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -112,6 +112,7 @@ public:
|
|||||||
|
|
||||||
CommandLine m_commandLine;
|
CommandLine m_commandLine;
|
||||||
Environment m_environment;
|
Environment m_environment;
|
||||||
|
QByteArray m_writeData;
|
||||||
bool m_haveEnv = false;
|
bool m_haveEnv = false;
|
||||||
bool m_useCtrlCStub = false;
|
bool m_useCtrlCStub = false;
|
||||||
bool m_lowPriority = false;
|
bool m_lowPriority = false;
|
||||||
@@ -228,6 +229,8 @@ void QtcProcess::setUseCtrlCStub(bool enabled)
|
|||||||
|
|
||||||
void QtcProcess::start()
|
void QtcProcess::start()
|
||||||
{
|
{
|
||||||
|
QTC_CHECK(d->m_writeData.isEmpty()); // FIXME: Use it.
|
||||||
|
|
||||||
if (d->m_commandLine.executable().needsDevice()) {
|
if (d->m_commandLine.executable().needsDevice()) {
|
||||||
QTC_ASSERT(s_remoteRunProcessHook, return);
|
QTC_ASSERT(s_remoteRunProcessHook, return);
|
||||||
s_remoteRunProcessHook(*this);
|
s_remoteRunProcessHook(*this);
|
||||||
@@ -780,6 +783,11 @@ void QtcProcess::setExitCodeInterpreter(const ExitCodeInterpreter &interpreter)
|
|||||||
d->m_exitCodeInterpreter = interpreter;
|
d->m_exitCodeInterpreter = interpreter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtcProcess::setWriteData(const QByteArray &writeData)
|
||||||
|
{
|
||||||
|
d->m_writeData = writeData;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef QT_GUI_LIB
|
#ifdef QT_GUI_LIB
|
||||||
static bool isGuiThread()
|
static bool isGuiThread()
|
||||||
{
|
{
|
||||||
@@ -787,7 +795,7 @@ static bool isGuiThread()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void QtcProcess::run(const CommandLine &cmd, const QByteArray &writeData)
|
void QtcProcess::run(const CommandLine &cmd)
|
||||||
{
|
{
|
||||||
// FIXME: Implement properly
|
// FIXME: Implement properly
|
||||||
if (cmd.executable().needsDevice()) {
|
if (cmd.executable().needsDevice()) {
|
||||||
@@ -815,13 +823,13 @@ void QtcProcess::run(const CommandLine &cmd, const QByteArray &writeData)
|
|||||||
// quoting of arguments than using QProcess::setArguments() beforehand and calling start()
|
// quoting of arguments than using QProcess::setArguments() beforehand and calling start()
|
||||||
// only with the OpenMode
|
// only with the OpenMode
|
||||||
setCommand(cmd);
|
setCommand(cmd);
|
||||||
if (!writeData.isEmpty()) {
|
if (!d->m_writeData.isEmpty()) {
|
||||||
connect(this, &QProcess::started, this, [this, writeData] {
|
connect(this, &QProcess::started, this, [this] {
|
||||||
write(writeData);
|
write(d->m_writeData);
|
||||||
closeWriteChannel();
|
closeWriteChannel();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
setOpenMode(writeData.isEmpty() ? QIODevice::ReadOnly : QIODevice::ReadWrite);
|
setOpenMode(d->m_writeData.isEmpty() ? QIODevice::ReadOnly : QIODevice::ReadWrite);
|
||||||
start();
|
start();
|
||||||
|
|
||||||
// On Windows, start failure is triggered immediately if the
|
// On Windows, start failure is triggered immediately if the
|
||||||
|
@@ -86,8 +86,11 @@ public:
|
|||||||
void setTimeOutMessageBoxEnabled(bool);
|
void setTimeOutMessageBoxEnabled(bool);
|
||||||
void setExitCodeInterpreter(const std::function<QtcProcess::Result(int)> &interpreter);
|
void setExitCodeInterpreter(const std::function<QtcProcess::Result(int)> &interpreter);
|
||||||
|
|
||||||
|
// FIXME: This is currently only used in run(), not in start()
|
||||||
|
void setWriteData(const QByteArray &writeData);
|
||||||
|
|
||||||
// Starts a nested event loop and runs the command
|
// Starts a nested event loop and runs the command
|
||||||
void run(const CommandLine &cmd, const QByteArray &writeData = {});
|
void run(const CommandLine &cmd);
|
||||||
// Starts the command blocking the UI fully
|
// Starts the command blocking the UI fully
|
||||||
void runBlocking(const CommandLine &cmd);
|
void runBlocking(const CommandLine &cmd);
|
||||||
|
|
||||||
|
@@ -721,8 +721,9 @@ SdkToolResult AndroidManager::runCommand(const CommandLine &command,
|
|||||||
Android::SdkToolResult cmdResult;
|
Android::SdkToolResult cmdResult;
|
||||||
SynchronousProcess cmdProc;
|
SynchronousProcess cmdProc;
|
||||||
cmdProc.setTimeoutS(timeoutS);
|
cmdProc.setTimeoutS(timeoutS);
|
||||||
|
cmdProc.setWriteData(writeData);
|
||||||
qCDebug(androidManagerLog) << "Running command (sync):" << command.toUserOutput();
|
qCDebug(androidManagerLog) << "Running command (sync):" << command.toUserOutput();
|
||||||
cmdProc.run(command, writeData);
|
cmdProc.run(command);
|
||||||
cmdResult.m_stdOut = cmdProc.stdOut().trimmed();
|
cmdResult.m_stdOut = cmdProc.stdOut().trimmed();
|
||||||
cmdResult.m_stdErr = cmdProc.stdErr().trimmed();
|
cmdResult.m_stdErr = cmdProc.stdErr().trimmed();
|
||||||
cmdResult.m_success = cmdProc.result() == QtcProcess::Finished;
|
cmdResult.m_success = cmdProc.result() == QtcProcess::Finished;
|
||||||
|
Reference in New Issue
Block a user