QProcess: Fix crash when calling closeWriteChannel on Windows
We must deleteLater the pipe writer in closeChannel, because if you call closeWriteChannel() from a slot that is connected to a signal emitted from QWindowsPipeWriter, we'd operate on a deleted object. For consistency, we're calling QWindowsPipeWriter::stop before deleteLater and deduplicate the code. Fixes: QTBUG-73778 Change-Id: I61d3dedf57e9fd02517a108d13ffc85e006330f6 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
parent
01f07fd2d1
commit
46a20b9024
@ -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)
|
void QProcessPrivate::closeChannel(Channel *channel)
|
||||||
{
|
{
|
||||||
if (channel == &stdinChannel) {
|
if (channel == &stdinChannel)
|
||||||
delete stdinChannel.writer;
|
deleteWorker(channel->writer);
|
||||||
stdinChannel.writer = 0;
|
else
|
||||||
} else if (channel->reader) {
|
deleteWorker(channel->reader);
|
||||||
channel->reader->stop();
|
|
||||||
channel->reader->deleteLater();
|
|
||||||
channel->reader = 0;
|
|
||||||
}
|
|
||||||
destroyPipe(channel->pipe);
|
destroyPipe(channel->pipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user