QProcess/Unix: do not toggle a state of the write notifier twice
_q_canWrite() unconditionally disabled the write notifier before the writing, and might have enabled it again afterwards. This caused unnecessary processing in the event dispatcher and could result in extra system calls. Actually setting the state at the moment when the write buffer size is determined is enough. Change-Id: I81f9ec27d95a5a9bdb83cc6a842b6ae95f002b96 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
24a0b641c1
commit
0873e5abb6
|
|
@ -1090,10 +1090,9 @@ bool QProcessPrivate::_q_canReadStandardError()
|
|||
*/
|
||||
bool QProcessPrivate::_q_canWrite()
|
||||
{
|
||||
if (stdinChannel.notifier)
|
||||
stdinChannel.notifier->setEnabled(false);
|
||||
|
||||
if (writeBuffer.isEmpty()) {
|
||||
if (stdinChannel.notifier)
|
||||
stdinChannel.notifier->setEnabled(false);
|
||||
#if defined QPROCESS_DEBUG
|
||||
qDebug("QProcessPrivate::canWrite(), not writing anything (empty write buffer).");
|
||||
#endif
|
||||
|
|
@ -1102,10 +1101,10 @@ bool QProcessPrivate::_q_canWrite()
|
|||
|
||||
const bool writeSucceeded = writeToStdin();
|
||||
|
||||
if (stdinChannel.notifier && !writeBuffer.isEmpty())
|
||||
stdinChannel.notifier->setEnabled(true);
|
||||
if (writeBuffer.isEmpty() && stdinChannel.closed)
|
||||
closeWriteChannel();
|
||||
else if (stdinChannel.notifier)
|
||||
stdinChannel.notifier->setEnabled(!writeBuffer.isEmpty());
|
||||
return writeSucceeded;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue