From 282c030785498d94c3ccee59a1a201f090e69248 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Mon, 13 May 2019 16:13:08 +0900 Subject: Remove property usage in QHttp2ProtocolHandler This helps to fix build without feature.properties Change-Id: Ia1fd2a1ca88105048e75694874058bb1292899a0 Reviewed-by: Timur Pocheptsov --- src/network/access/qhttp2protocolhandler.cpp | 24 ++++++++++++++++++------ src/network/access/qhttp2protocolhandler_p.h | 2 ++ 2 files changed, 20 insertions(+), 6 deletions(-) (limited to 'src/network') diff --git a/src/network/access/qhttp2protocolhandler.cpp b/src/network/access/qhttp2protocolhandler.cpp index 87a70d8a55..93afcf0ee1 100644 --- a/src/network/access/qhttp2protocolhandler.cpp +++ b/src/network/access/qhttp2protocolhandler.cpp @@ -219,7 +219,8 @@ void QHttp2ProtocolHandler::_q_uploadDataReadyRead() auto data = qobject_cast(sender()); Q_ASSERT(data); - const qint32 streamID = data->property("HTTP2StreamID").toInt(); + const qint32 streamID = streamIDs.value(data); + Q_ASSERT(streamID != 0); Q_ASSERT(activeStreams.contains(streamID)); auto &stream = activeStreams[streamID]; @@ -234,7 +235,7 @@ void QHttp2ProtocolHandler::_q_uploadDataReadyRead() void QHttp2ProtocolHandler::_q_replyDestroyed(QObject *reply) { - const quint32 streamID = reply->property("HTTP2StreamID").toInt(); + const quint32 streamID = streamIDs.take(reply); if (activeStreams.contains(streamID)) { sendRST_STREAM(streamID, CANCEL); markAsReset(streamID); @@ -242,6 +243,11 @@ void QHttp2ProtocolHandler::_q_replyDestroyed(QObject *reply) } } +void QHttp2ProtocolHandler::_q_uploadDataDestroyed(QObject *uploadData) +{ + streamIDs.remove(uploadData); +} + void QHttp2ProtocolHandler::_q_readyRead() { _q_receiveReply(); @@ -1249,7 +1255,7 @@ quint32 QHttp2ProtocolHandler::createNewStream(const HttpMessagePair &message, b replyPrivate->connection = m_connection; replyPrivate->connectionChannel = m_channel; reply->setSpdyWasUsed(true); - reply->setProperty("HTTP2StreamID", newStreamID); + streamIDs.insert(reply, newStreamID); connect(reply, SIGNAL(destroyed(QObject*)), this, SLOT(_q_replyDestroyed(QObject*))); @@ -1261,7 +1267,9 @@ quint32 QHttp2ProtocolHandler::createNewStream(const HttpMessagePair &message, b if (auto src = newStream.data()) { connect(src, SIGNAL(readyRead()), this, SLOT(_q_uploadDataReadyRead()), Qt::QueuedConnection); - src->setProperty("HTTP2StreamID", newStreamID); + connect(src, &QHttp2ProtocolHandler::destroyed, + this, &QHttp2ProtocolHandler::_q_uploadDataDestroyed); + streamIDs.insert(src, newStreamID); } } @@ -1343,10 +1351,14 @@ void QHttp2ProtocolHandler::deleteActiveStream(quint32 streamID) { if (activeStreams.contains(streamID)) { auto &stream = activeStreams[streamID]; - if (stream.reply()) + if (stream.reply()) { stream.reply()->disconnect(this); - if (stream.data()) + streamIDs.remove(stream.reply()); + } + if (stream.data()) { stream.data()->disconnect(this); + streamIDs.remove(stream.data()); + } activeStreams.remove(streamID); } diff --git a/src/network/access/qhttp2protocolhandler_p.h b/src/network/access/qhttp2protocolhandler_p.h index 9165808302..b582123961 100644 --- a/src/network/access/qhttp2protocolhandler_p.h +++ b/src/network/access/qhttp2protocolhandler_p.h @@ -93,6 +93,7 @@ public: private slots: void _q_uploadDataReadyRead(); void _q_replyDestroyed(QObject* reply); + void _q_uploadDataDestroyed(QObject* uploadData); private: using Stream = Http2::Stream; @@ -156,6 +157,7 @@ private: HPack::Decoder decoder; HPack::Encoder encoder; + QHash streamIDs; QHash activeStreams; std::deque suspendedStreams[3]; // 3 for priorities: High, Normal, Low. static const std::deque::size_type maxRecycledStreams; -- cgit v1.2.3