QProcess/Win: improve reading in waitForBytesWritten()
On Windows, tryReadFromChannel() just publishes the data that was already buffered by the pipe reader. Reading from the pipe was still possible only because the pipe writer enters an alertable wait state which can trigger an I/O callback for the read operation as well. This made the implementation unclear and tied to APC behavior. To avoid this, we now call the "proper" pipe reader wait function instead, which also unifies the code with the other waitFor...() implementations. Change-Id: I7376d7973477a722472ff8763f95f39e6ea2fce9 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>bb10
parent
6035fd8f2c
commit
80b7ef559a
|
|
@ -758,18 +758,12 @@ bool QProcessPrivate::waitForBytesWritten(int msecs)
|
|||
return true;
|
||||
|
||||
// If we wouldn't write anything, check if we can read stdout.
|
||||
if (stdoutChannel.pipe[0] != INVALID_Q_PIPE
|
||||
&& bytesAvailableInChannel(&stdoutChannel) != 0) {
|
||||
tryReadFromChannel(&stdoutChannel);
|
||||
if (stdoutChannel.reader && stdoutChannel.reader->waitForReadyRead(0))
|
||||
timer.resetIncrements();
|
||||
}
|
||||
|
||||
// Check if we can read stderr.
|
||||
if (stderrChannel.pipe[0] != INVALID_Q_PIPE
|
||||
&& bytesAvailableInChannel(&stderrChannel) != 0) {
|
||||
tryReadFromChannel(&stderrChannel);
|
||||
if (stderrChannel.reader && stderrChannel.reader->waitForReadyRead(0))
|
||||
timer.resetIncrements();
|
||||
}
|
||||
|
||||
// Check if the process died while reading.
|
||||
if (!pid)
|
||||
|
|
|
|||
Loading…
Reference in New Issue