diff --git a/src/network/access/qhttp2connection.cpp b/src/network/access/qhttp2connection.cpp index 61bd0d3174f..20dd4118617 100644 --- a/src/network/access/qhttp2connection.cpp +++ b/src/network/access/qhttp2connection.cpp @@ -277,7 +277,7 @@ void QHttp2Stream::sendDATA(QIODevice *device, bool endStream) qCDebug(qHttp2ConnectionLog, "[%p] starting sendDATA on stream %u, of device: %p", getConnection(), m_streamID, device); auto *byteDevice = QNonContiguousByteDeviceFactory::create(device); - connect(this, &QHttp2Stream::uploadFinished, byteDevice, &QObject::deleteLater); + m_owningByteDevice = true; byteDevice->setParent(this); m_uploadDevice = device; sendDATA(byteDevice, endStream); @@ -423,6 +423,10 @@ void QHttp2Stream::finishSendDATA() disconnect(m_uploadByteDevice, nullptr, this, nullptr); m_uploadDevice = nullptr; + if (m_owningByteDevice) { + m_owningByteDevice = false; + delete m_uploadByteDevice; + } m_uploadByteDevice = nullptr; emit uploadFinished(); } diff --git a/src/network/access/qhttp2connection_p.h b/src/network/access/qhttp2connection_p.h index c5ea94a6572..d5984c79662 100644 --- a/src/network/access/qhttp2connection_p.h +++ b/src/network/access/qhttp2connection_p.h @@ -196,6 +196,7 @@ private: State m_state = State::Idle; HPack::HttpHeader m_headers; bool m_isReserved = false; + bool m_owningByteDevice = false; friend tst_QHttp2Connection; };