From dcdab683d6bfb6b0ad81b5903236ae70a71246e4 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 16 Jan 2012 12:02:47 +0100 Subject: QProcess/Win: use asynchronous I/O for reading stdout and stderr This saves us from using the 100 ms polling timer to read process output. Task-number: QTBUG-23012 Change-Id: I3f9398d7a4d30826d2d89ac04bd2fd031500ff57 Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qprocess.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src/corelib/io/qprocess.cpp') diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index fe9810e7cb..124be801f5 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -761,8 +761,6 @@ QProcessPrivate::QProcessPrivate() exitStatus = QProcess::NormalExit; startupSocketNotifier = 0; deathNotifier = 0; - notifier = 0; - pipeWriter = 0; childStartedPipe[0] = INVALID_Q_PIPE; childStartedPipe[1] = INVALID_Q_PIPE; deathPipe[0] = INVALID_Q_PIPE; @@ -773,6 +771,9 @@ QProcessPrivate::QProcessPrivate() emittedReadyRead = false; emittedBytesWritten = false; #ifdef Q_OS_WIN + notifier = 0; + stdoutReader = 0; + stderrReader = 0; pipeWriter = 0; processFinishedNotifier = 0; #endif // Q_OS_WIN @@ -843,13 +844,15 @@ void QProcessPrivate::cleanup() qDeleteInEventHandler(deathNotifier); deathNotifier = 0; } +#ifdef Q_OS_WIN if (notifier) { qDeleteInEventHandler(notifier); notifier = 0; } - destroyPipe(stdoutChannel.pipe); - destroyPipe(stderrChannel.pipe); - destroyPipe(stdinChannel.pipe); +#endif + destroyChannel(&stdoutChannel); + destroyChannel(&stderrChannel); + destroyChannel(&stdinChannel); destroyPipe(childStartedPipe); destroyPipe(deathPipe); #ifdef Q_OS_UNIX @@ -873,7 +876,7 @@ bool QProcessPrivate::_q_canReadStandardOutput() if (available == 0) { if (stdoutChannel.notifier) stdoutChannel.notifier->setEnabled(false); - destroyPipe(stdoutChannel.pipe); + destroyChannel(&stdoutChannel); #if defined QPROCESS_DEBUG qDebug("QProcessPrivate::canReadStandardOutput(), 0 bytes available"); #endif @@ -928,7 +931,7 @@ bool QProcessPrivate::_q_canReadStandardError() if (available == 0) { if (stderrChannel.notifier) stderrChannel.notifier->setEnabled(false); - destroyPipe(stderrChannel.pipe); + destroyChannel(&stderrChannel); return false; } @@ -981,7 +984,7 @@ bool QProcessPrivate::_q_canWrite() qint64 written = writeToStdin(writeBuffer.readPointer(), writeBuffer.nextDataBlockSize()); if (written < 0) { - destroyPipe(stdinChannel.pipe); + destroyChannel(&stdinChannel); processError = QProcess::WriteError; q->setErrorString(QProcess::tr("Error writing to process")); emit q->error(processError); @@ -1125,7 +1128,7 @@ void QProcessPrivate::closeWriteChannel() // instead. flushPipeWriter(); #endif - destroyPipe(stdinChannel.pipe); + destroyChannel(&stdinChannel); } /*! -- cgit v1.2.3