QNetworkAccessManager: Avoid unnecessary calls to sender()
As it searches through all connections, of which we have multiple for each network reply. Fixes: QTBUG-81336 Change-Id: Iba28278edae5f254bf884f427e0944d348b47d03 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
parent
bd828bacb9
commit
6faaef5a66
@ -1753,16 +1753,13 @@ void QNetworkAccessManager::setTransferTimeout(int timeout)
|
|||||||
d_func()->transferTimeout = timeout;
|
d_func()->transferTimeout = timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QNetworkAccessManagerPrivate::_q_replyFinished()
|
void QNetworkAccessManagerPrivate::_q_replyFinished(QNetworkReply *reply)
|
||||||
{
|
{
|
||||||
Q_Q(QNetworkAccessManager);
|
Q_Q(QNetworkAccessManager);
|
||||||
|
|
||||||
QNetworkReply *reply = qobject_cast<QNetworkReply *>(q->sender());
|
emit q->finished(reply);
|
||||||
if (reply) {
|
if (reply->request().attribute(QNetworkRequest::AutoDeleteReplyOnFinishAttribute, false).toBool())
|
||||||
emit q->finished(reply);
|
QMetaObject::invokeMethod(reply, [reply] { reply->deleteLater(); }, Qt::QueuedConnection);
|
||||||
if (reply->request().attribute(QNetworkRequest::AutoDeleteReplyOnFinishAttribute, false).toBool())
|
|
||||||
QMetaObject::invokeMethod(reply, [reply] { reply->deleteLater(); }, Qt::QueuedConnection);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef QT_NO_BEARERMANAGEMENT
|
#ifndef QT_NO_BEARERMANAGEMENT
|
||||||
// If there are no active requests, release our reference to the network session.
|
// If there are no active requests, release our reference to the network session.
|
||||||
@ -1774,13 +1771,11 @@ void QNetworkAccessManagerPrivate::_q_replyFinished()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void QNetworkAccessManagerPrivate::_q_replyEncrypted()
|
void QNetworkAccessManagerPrivate::_q_replyEncrypted(QNetworkReply *reply)
|
||||||
{
|
{
|
||||||
#ifndef QT_NO_SSL
|
#ifndef QT_NO_SSL
|
||||||
Q_Q(QNetworkAccessManager);
|
Q_Q(QNetworkAccessManager);
|
||||||
QNetworkReply *reply = qobject_cast<QNetworkReply *>(q->sender());
|
emit q->encrypted(reply);
|
||||||
if (reply)
|
|
||||||
emit q->encrypted(reply);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1812,11 +1807,13 @@ QNetworkReply *QNetworkAccessManagerPrivate::postProcess(QNetworkReply *reply)
|
|||||||
{
|
{
|
||||||
Q_Q(QNetworkAccessManager);
|
Q_Q(QNetworkAccessManager);
|
||||||
QNetworkReplyPrivate::setManager(reply, q);
|
QNetworkReplyPrivate::setManager(reply, q);
|
||||||
q->connect(reply, SIGNAL(finished()), SLOT(_q_replyFinished()));
|
q->connect(reply, &QNetworkReply::finished, reply,
|
||||||
|
[this, reply]() { _q_replyFinished(reply); });
|
||||||
#ifndef QT_NO_SSL
|
#ifndef QT_NO_SSL
|
||||||
/* In case we're compiled without SSL support, we don't have this signal and we need to
|
/* In case we're compiled without SSL support, we don't have this signal and we need to
|
||||||
* avoid getting a connection error. */
|
* avoid getting a connection error. */
|
||||||
q->connect(reply, SIGNAL(encrypted()), SLOT(_q_replyEncrypted()));
|
q->connect(reply, &QNetworkReply::encrypted, reply,
|
||||||
|
[this, reply]() { _q_replyEncrypted(reply); });
|
||||||
q->connect(reply, SIGNAL(sslErrors(QList<QSslError>)), SLOT(_q_replySslErrors(QList<QSslError>)));
|
q->connect(reply, SIGNAL(sslErrors(QList<QSslError>)), SLOT(_q_replySslErrors(QList<QSslError>)));
|
||||||
q->connect(reply, SIGNAL(preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator*)), SLOT(_q_replyPreSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator*)));
|
q->connect(reply, SIGNAL(preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator*)), SLOT(_q_replyPreSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator*)));
|
||||||
#endif
|
#endif
|
||||||
|
@ -208,8 +208,6 @@ private:
|
|||||||
friend class QNetworkReplyWasmImpl;
|
friend class QNetworkReplyWasmImpl;
|
||||||
#endif
|
#endif
|
||||||
Q_DECLARE_PRIVATE(QNetworkAccessManager)
|
Q_DECLARE_PRIVATE(QNetworkAccessManager)
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_replyFinished())
|
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_replyEncrypted())
|
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_replySslErrors(QList<QSslError>))
|
Q_PRIVATE_SLOT(d_func(), void _q_replySslErrors(QList<QSslError>))
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_replyPreSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator*))
|
Q_PRIVATE_SLOT(d_func(), void _q_replyPreSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator*))
|
||||||
#ifndef QT_NO_BEARERMANAGEMENT
|
#ifndef QT_NO_BEARERMANAGEMENT
|
||||||
|
@ -120,8 +120,8 @@ public:
|
|||||||
QThread * createThread();
|
QThread * createThread();
|
||||||
void destroyThread();
|
void destroyThread();
|
||||||
|
|
||||||
void _q_replyFinished();
|
void _q_replyFinished(QNetworkReply *reply);
|
||||||
void _q_replyEncrypted();
|
void _q_replyEncrypted(QNetworkReply *reply);
|
||||||
void _q_replySslErrors(const QList<QSslError> &errors);
|
void _q_replySslErrors(const QList<QSslError> &errors);
|
||||||
void _q_replyPreSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator *authenticator);
|
void _q_replyPreSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator *authenticator);
|
||||||
QNetworkReply *postProcess(QNetworkReply *reply);
|
QNetworkReply *postProcess(QNetworkReply *reply);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user