summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qprocess.cpp
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@theqtcompany.com>2015-04-09 11:24:15 +0200
committerJoerg Bornemann <joerg.bornemann@theqtcompany.com>2015-04-13 14:51:57 +0000
commit96cc8eec9b32f4e80c2d748687c485bc79133d39 (patch)
tree5902bb2cc6aa7e70070c46282169be3ae57a239f /src/corelib/io/qprocess.cpp
parent95b481ea6dfa901c23b012085527769f9b5823c9 (diff)
remove the "wonderful Windows notifier" from QProcess
Remove the 100 ms timer that was used to nudge QProcess to write data to the child's stdin. Instead, react on the canWrite() signal of QWindowsPipeWriter. QProcess::writeData needs to call _q_canWrite via the event loop to start the write operation. The socket notifier code was never in use on Windows. Task-number: QTBUG-45457 Change-Id: I99c956ba5f2169f80068eee206543ceb9788b2e0 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Diffstat (limited to 'src/corelib/io/qprocess.cpp')
-rw-r--r--src/corelib/io/qprocess.cpp34
1 files changed, 27 insertions, 7 deletions
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 7d7cdef203..ead04791e5 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -36,6 +36,9 @@
#include <qdebug.h>
#include <qdir.h>
+#if defined(Q_OS_WIN)
+#include <qtimer.h>
+#endif
#if defined QPROCESS_DEBUG
#include <qstring.h>
#include <ctype.h>
@@ -819,7 +822,7 @@ QProcessPrivate::QProcessPrivate()
emittedReadyRead = false;
emittedBytesWritten = false;
#ifdef Q_OS_WIN
- notifier = 0;
+ stdinWriteTrigger = 0;
processFinishedNotifier = 0;
#endif // Q_OS_WIN
}
@@ -848,6 +851,10 @@ void QProcessPrivate::cleanup()
delete pid;
pid = 0;
}
+ if (stdinWriteTrigger) {
+ delete stdinWriteTrigger;
+ stdinWriteTrigger = 0;
+ }
if (processFinishedNotifier) {
delete processFinishedNotifier;
processFinishedNotifier = 0;
@@ -878,12 +885,6 @@ void QProcessPrivate::cleanup()
delete deathNotifier;
deathNotifier = 0;
}
-#ifdef Q_OS_WIN
- if (notifier) {
- delete notifier;
- notifier = 0;
- }
-#endif
closeChannel(&stdoutChannel);
closeChannel(&stderrChannel);
closeChannel(&stdinChannel);
@@ -1953,10 +1954,24 @@ qint64 QProcess::writeData(const char *data, qint64 len)
return 0;
}
+#if defined(Q_OS_WIN)
+ if (!d->stdinWriteTrigger) {
+ d->stdinWriteTrigger = new QTimer;
+ d->stdinWriteTrigger->setSingleShot(true);
+ QObjectPrivate::connect(d->stdinWriteTrigger, &QTimer::timeout,
+ d, &QProcessPrivate::_q_canWrite);
+ }
+#endif
+
if (len == 1) {
d->stdinChannel.buffer.putChar(*data);
+#ifdef Q_OS_WIN
+ if (!d->stdinWriteTrigger->isActive())
+ d->stdinWriteTrigger->start();
+#else
if (d->stdinChannel.notifier)
d->stdinChannel.notifier->setEnabled(true);
+#endif
#if defined QPROCESS_DEBUG
qDebug("QProcess::writeData(%p \"%s\", %lld) == 1 (written to buffer)",
data, qt_prettyDebug(data, len, 16).constData(), len);
@@ -1966,8 +1981,13 @@ qint64 QProcess::writeData(const char *data, qint64 len)
char *dest = d->stdinChannel.buffer.reserve(len);
memcpy(dest, data, len);
+#ifdef Q_OS_WIN
+ if (!d->stdinWriteTrigger->isActive())
+ d->stdinWriteTrigger->start();
+#else
if (d->stdinChannel.notifier)
d->stdinChannel.notifier->setEnabled(true);
+#endif
#if defined QPROCESS_DEBUG
qDebug("QProcess::writeData(%p \"%s\", %lld) == %lld (written to buffer)",
data, qt_prettyDebug(data, len, 16).constData(), len, len);