From 699f72278952cecf44976da0a044a698ced76171 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Tue, 18 Jun 2024 16:39:04 +0200 Subject: [PATCH] http2: delete byte device without deleteLater MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If we own the byte device we can just delete it directly when we are done with it. Change-Id: I9da99943ff61925f6f5416df403bcd747c2558d5 Reviewed-by: Dennis Oberst Reviewed-by: Øystein Heskestad (cherry picked from commit 4bc878ff4fbacd39d4c0ed1e8e742fd18fa74fed) Reviewed-by: Alexey Edelev --- src/network/access/qhttp2connection.cpp | 6 +++++- src/network/access/qhttp2connection_p.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) 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; };