diff options
author | Christian Stenger <christian.stenger@qt.io> | 2021-01-11 08:25:06 +0100 |
---|---|---|
committer | Christian Stenger <christian.stenger@qt.io> | 2021-01-11 14:32:56 +0000 |
commit | 85bdcf819f2b599b977ea87bcd9160c04a98259e (patch) | |
tree | 8fe9d5ebf2335c017fed938667a08e5638a76820 | |
parent | 86348d562214a27574ddbd65825414ae7e731438 (diff) | |
download | qt-creator-85bdcf819f2b599b977ea87bcd9160c04a98259e.tar.gz |
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>
-rw-r--r-- | src/libs/utils/synchronousprocess.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/libs/utils/synchronousprocess.cpp b/src/libs/utils/synchronousprocess.cpp index 0845e4b803..d722801efb 100644 --- a/src/libs/utils/synchronousprocess.cpp +++ b/src/libs/utils/synchronousprocess.cpp @@ -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()); - connect(&d->m_process, &QProcess::started, this, [this, writeData] { - d->m_process.write(writeData); - d->m_process.closeWriteChannel(); - }); + 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 |