summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorMårten Nordheim <marten.nordheim@qt.io>2022-03-04 12:28:49 +0100
committerMårten Nordheim <marten.nordheim@qt.io>2022-03-08 15:44:17 +0100
commit034d8898f8166423db085da529787e56204c8e15 (patch)
treef58e930c7880d1cd79cd39745ed366d27dcd9e55 /src/network
parent87725ee75981ec9ab25456c41acc74681c85ae2e (diff)
Fix deprecated uses of QScopedPointer
By changing it to unique_ptr. Pick-to: 6.2 6.3 Change-Id: I91abb69445b537d4c95983ae735341882352b29d Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/network')
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel.cpp24
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel_p.h4
-rw-r--r--src/network/socket/qsocks5socketengine.cpp6
3 files changed, 20 insertions, 14 deletions
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp
index 17c0acca57..34636f34f1 100644
--- a/src/network/access/qhttpnetworkconnectionchannel.cpp
+++ b/src/network/access/qhttpnetworkconnectionchannel.cpp
@@ -58,6 +58,8 @@
#include "private/qnetconmonitor_p.h"
+#include <memory>
+
QT_BEGIN_NAMESPACE
namespace
@@ -242,7 +244,7 @@ void QHttpNetworkConnectionChannel::abort()
bool QHttpNetworkConnectionChannel::sendRequest()
{
- Q_ASSERT(!protocolHandler.isNull());
+ Q_ASSERT(protocolHandler);
return protocolHandler->sendRequest();
}
@@ -255,7 +257,7 @@ bool QHttpNetworkConnectionChannel::sendRequest()
void QHttpNetworkConnectionChannel::sendRequestDelayed()
{
QMetaObject::invokeMethod(this, [this] {
- Q_ASSERT(!protocolHandler.isNull());
+ Q_ASSERT(protocolHandler);
if (reply)
protocolHandler->sendRequest();
}, Qt::ConnectionType::QueuedConnection);
@@ -263,13 +265,13 @@ void QHttpNetworkConnectionChannel::sendRequestDelayed()
void QHttpNetworkConnectionChannel::_q_receiveReply()
{
- Q_ASSERT(!protocolHandler.isNull());
+ Q_ASSERT(protocolHandler);
protocolHandler->_q_receiveReply();
}
void QHttpNetworkConnectionChannel::_q_readyRead()
{
- Q_ASSERT(!protocolHandler.isNull());
+ Q_ASSERT(protocolHandler);
protocolHandler->_q_readyRead();
}
@@ -478,18 +480,18 @@ void QHttpNetworkConnectionChannel::allDone()
// trick with ProtocolHandlerDeleter, a QObject-derived class.
// These dances below just make it somewhat exception-safe.
// 1. Create a new owner:
- QAbstractProtocolHandler *oldHandler = protocolHandler.data();
- QScopedPointer<ProtocolHandlerDeleter> deleter(new ProtocolHandlerDeleter(oldHandler));
+ QAbstractProtocolHandler *oldHandler = protocolHandler.get();
+ auto deleter = std::make_unique<ProtocolHandlerDeleter>(oldHandler);
// 2. Retire the old one:
- protocolHandler.take();
+ Q_UNUSED(protocolHandler.release());
// 3. Call 'deleteLater':
deleter->deleteLater();
// 3. Give up the ownerthip:
- deleter.take();
+ Q_UNUSED(deleter.release());
connection->fillHttp2Queue();
protocolHandler.reset(new QHttp2ProtocolHandler(this));
- QHttp2ProtocolHandler *h2c = static_cast<QHttp2ProtocolHandler *>(protocolHandler.data());
+ QHttp2ProtocolHandler *h2c = static_cast<QHttp2ProtocolHandler *>(protocolHandler.get());
QMetaObject::invokeMethod(h2c, "_q_receiveReply", Qt::QueuedConnection);
QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
// If we only had one request sent with H2 allowed, we may fail to send
@@ -995,11 +997,11 @@ void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socket
// we do not resend, but must report errors if any request is in progress (note, while
// not in its sendRequest(), protocol handler switches the channel to IdleState, thus
// this check is under this condition in 'if'):
- if (protocolHandler.data()) {
+ if (protocolHandler) {
if (connection->connectionType() == QHttpNetworkConnection::ConnectionTypeHTTP2Direct
|| (connection->connectionType() == QHttpNetworkConnection::ConnectionTypeHTTP2
&& switchedToHttp2)) {
- auto h2Handler = static_cast<QHttp2ProtocolHandler *>(protocolHandler.data());
+ auto h2Handler = static_cast<QHttp2ProtocolHandler *>(protocolHandler.get());
h2Handler->handleConnectionClosure();
}
}
diff --git a/src/network/access/qhttpnetworkconnectionchannel_p.h b/src/network/access/qhttpnetworkconnectionchannel_p.h
index ecf1e20106..491f5121ac 100644
--- a/src/network/access/qhttpnetworkconnectionchannel_p.h
+++ b/src/network/access/qhttpnetworkconnectionchannel_p.h
@@ -78,6 +78,8 @@
#include <QtCore/qscopedpointer.h>
+#include <memory>
+
QT_REQUIRE_CONFIG(http);
QT_BEGIN_NAMESPACE
@@ -120,7 +122,7 @@ public:
QAuthenticator proxyAuthenticator;
bool authenticationCredentialsSent;
bool proxyCredentialsSent;
- QScopedPointer<QAbstractProtocolHandler> protocolHandler;
+ std::unique_ptr<QAbstractProtocolHandler> protocolHandler;
QMultiMap<int, HttpMessagePair> h2RequestsToSend;
bool switchedToHttp2 = false;
#ifndef QT_NO_SSL
diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp
index 3708ce9df2..ed16e2d855 100644
--- a/src/network/socket/qsocks5socketengine.cpp
+++ b/src/network/socket/qsocks5socketengine.cpp
@@ -56,6 +56,8 @@
#include <qendian.h>
#include <qnetworkinterface.h>
+#include <memory>
+
QT_BEGIN_NAMESPACE
static const int MaxWriteBufferSize = 128*1024;
@@ -1912,9 +1914,9 @@ QSocks5SocketEngineHandler::createSocketEngine(QAbstractSocket::SocketType socke
QSOCKS5_DEBUG << "not proxying";
return nullptr;
}
- QScopedPointer<QSocks5SocketEngine> engine(new QSocks5SocketEngine(parent));
+ auto engine = std::make_unique<QSocks5SocketEngine>(parent);
engine->setProxy(proxy);
- return engine.take();
+ return engine.release();
}
QAbstractSocketEngine *QSocks5SocketEngineHandler::createSocketEngine(qintptr socketDescriptor, QObject *parent)