summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qprocess_win.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/io/qprocess_win.cpp')
-rw-r--r--src/corelib/io/qprocess_win.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp
index cb4b2f9f91..3ba86063e3 100644
--- a/src/corelib/io/qprocess_win.cpp
+++ b/src/corelib/io/qprocess_win.cpp
@@ -362,16 +362,22 @@ void QProcessPrivate::destroyPipe(Q_PIPE pipe[2])
}
}
+template <class T>
+void deleteWorker(T *&worker)
+{
+ if (!worker)
+ return;
+ worker->stop();
+ worker->deleteLater();
+ worker = nullptr;
+}
+
void QProcessPrivate::closeChannel(Channel *channel)
{
- if (channel == &stdinChannel) {
- delete stdinChannel.writer;
- stdinChannel.writer = 0;
- } else if (channel->reader) {
- channel->reader->stop();
- channel->reader->deleteLater();
- channel->reader = 0;
- }
+ if (channel == &stdinChannel)
+ deleteWorker(channel->writer);
+ else
+ deleteWorker(channel->reader);
destroyPipe(channel->pipe);
}