Remove property usage in QHttp2ProtocolHandler

This helps to fix build without feature.properties

Change-Id: Ia1fd2a1ca88105048e75694874058bb1292899a0
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
bb10
Tasuku Suzuki 2019-05-13 16:13:08 +09:00
parent a03270f891
commit 282c030785
2 changed files with 20 additions and 6 deletions

View File

@ -219,7 +219,8 @@ void QHttp2ProtocolHandler::_q_uploadDataReadyRead()
auto data = qobject_cast<QNonContiguousByteDevice *>(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);
}

View File

@ -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<QObject *, int> streamIDs;
QHash<quint32, Stream> activeStreams;
std::deque<quint32> suspendedStreams[3]; // 3 for priorities: High, Normal, Low.
static const std::deque<quint32>::size_type maxRecycledStreams;