From 85bdcf819f2b599b977ea87bcd9160c04a98259e Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Mon, 11 Jan 2021 08:25:06 +0100 Subject: [PATCH] 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 Reviewed-by: hjk --- src/libs/utils/synchronousprocess.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/libs/utils/synchronousprocess.cpp b/src/libs/utils/synchronousprocess.cpp index 0845e4b8034..d722801efb6 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