http2: delete byte device without deleteLater

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 <dennis.oberst@qt.io>
Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io>
(cherry picked from commit 4bc878ff4fbacd39d4c0ed1e8e742fd18fa74fed)
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
Mårten Nordheim 2024-06-18 16:39:04 +02:00
parent 4cb06919aa
commit 699f722789
2 changed files with 6 additions and 1 deletions

View File

@ -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();
}

View File

@ -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;
};