diff options
author | Alex Trotsenko <alex1973tr@gmail.com> | 2017-09-02 17:09:59 +0300 |
---|---|---|
committer | Alex Trotsenko <alex1973tr@gmail.com> | 2017-12-02 19:42:11 +0000 |
commit | 0873e5abb6cce584f5bebed013908ad998713f94 (patch) | |
tree | 9c421ea0cd6ab4541b1244ef9bcc1f4fed964b07 /src/corelib | |
parent | 24a0b641c13f0002416bbbcf9908a18070fcf5eb (diff) |
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>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/io/qprocess.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 7ed319f5f1..41f4b2aa83 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -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; } |