diff options
author | Alex Trotsenko <alex1973tr@gmail.com> | 2021-03-19 10:10:28 +0200 |
---|---|---|
committer | Alex Trotsenko <alex1973tr@gmail.com> | 2021-03-25 10:35:04 +0200 |
commit | 856e0a187fe44eb87e267e8607db34f05e84e84c (patch) | |
tree | 039507637f399ffa137f586231813657b0a67d65 | |
parent | 3dcdd89dd158306784159d673a1be76a32036b14 (diff) |
QProcess/Win: simplify logic inside waitForBytesWritten()
Also, remove obsolete comments and an unnecessary check.
Change-Id: If64fa660d5434de94edfa48aafcaeb755aa8d68c
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
-rw-r--r-- | src/corelib/io/qprocess_win.cpp | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp index 3bdf070be4..84fbeb539d 100644 --- a/src/corelib/io/qprocess_win.cpp +++ b/src/corelib/io/qprocess_win.cpp @@ -693,29 +693,14 @@ bool QProcessPrivate::waitForBytesWritten(const QDeadlineTimer &deadline) QIncrementalSleepTimer timer(deadline.remainingTime()); forever { - bool pendingDataInPipe = stdinChannel.writer && stdinChannel.writer->bytesToWrite(); - - // If we don't have pending data, and our write buffer is - // empty, we fail. - if (!pendingDataInPipe && writeBuffer.isEmpty()) + // If no write is pending, try to start one. However, at entry into + // the loop the write buffer can be empty to start with, in which + // case _q_caWrite() fails immediately. + if (pipeWriterBytesToWrite() == 0 && !_q_canWrite()) return false; - // If we don't have pending data and we do have data in our - // write buffer, try to flush that data over to the pipe - // writer. Fail on error. - if (!pendingDataInPipe) { - if (!_q_canWrite()) - return false; - } - - // Wait for the pipe writer to acknowledge that it has - // written. This will succeed if either the pipe writer has - // already written the data, or if it manages to write data - // within the given timeout. If the write buffer was non-empty - // and the stdinChannel.writer is now dead, that means _q_canWrite() - // destroyed the writer after it successfully wrote the last - // batch. - if (!stdinChannel.writer || stdinChannel.writer->waitForWrite(0)) + Q_ASSERT(stdinChannel.writer); + if (stdinChannel.writer->waitForWrite(0)) return true; // If we wouldn't write anything, check if we can read stdout. |