forked from qt-creator/qt-creator
Utils: Only write data to process if there is any
This avoids the warning QIODevice::write (QProcess): ReadOnly device in cases where the process is run inside a read only directory even when the process has no input. Change-Id: I9434c738e9cf94c348f1437ebf15e1c7574cde94 Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -481,10 +481,12 @@ SynchronousProcessResponse SynchronousProcess::run(const CommandLine &cmd,
|
||||
// only with the OpenMode
|
||||
d->m_process.setProgram(cmd.executable().toString());
|
||||
d->m_process.setArguments(cmd.splitArguments());
|
||||
if (!writeData.isEmpty()) {
|
||||
connect(&d->m_process, &QProcess::started, this, [this, writeData] {
|
||||
d->m_process.write(writeData);
|
||||
d->m_process.closeWriteChannel();
|
||||
});
|
||||
}
|
||||
d->m_process.start(writeData.isEmpty() ? QIODevice::ReadOnly : QIODevice::ReadWrite);
|
||||
|
||||
// On Windows, start failure is triggered immediately if the
|
||||
|
Reference in New Issue
Block a user