diff --git a/src/corelib/io/qnoncontiguousbytedevice.cpp b/src/corelib/io/qnoncontiguousbytedevice.cpp index cf2da0c8963..73075c532fd 100644 --- a/src/corelib/io/qnoncontiguousbytedevice.cpp +++ b/src/corelib/io/qnoncontiguousbytedevice.cpp @@ -227,10 +227,9 @@ qint64 QNonContiguousByteDeviceByteArrayImpl::pos() const return currentPosition; } -QNonContiguousByteDeviceRingBufferImpl::QNonContiguousByteDeviceRingBufferImpl(QSharedPointer rb) - : QNonContiguousByteDevice(), currentPosition(0) +QNonContiguousByteDeviceRingBufferImpl::QNonContiguousByteDeviceRingBufferImpl(std::shared_ptr rb) + : QNonContiguousByteDevice(), ringBuffer(std::move(rb)) { - ringBuffer = rb; } QNonContiguousByteDeviceRingBufferImpl::~QNonContiguousByteDeviceRingBufferImpl() @@ -495,44 +494,44 @@ QNonContiguousByteDevice *QNonContiguousByteDeviceFactory::create(QIODevice *dev } /*! - Create a QNonContiguousByteDevice out of a QIODevice, return it in a QSharedPointer. + Create a QNonContiguousByteDevice out of a QIODevice, return it in a std::shared_ptr. For QFile, QBuffer and all other QIODevice, sequential or not. \internal */ -QSharedPointer QNonContiguousByteDeviceFactory::createShared(QIODevice *device) +std::shared_ptr QNonContiguousByteDeviceFactory::createShared(QIODevice *device) { // shortcut if it is a QBuffer if (QBuffer *buffer = qobject_cast(device)) - return QSharedPointer::create(buffer); + return std::make_shared(buffer); // ### FIXME special case if device is a QFile that supports map() // then we can actually deal with the file without using read/peek // generic QIODevice - return QSharedPointer::create(device); // FIXME + return std::make_shared(device); // FIXME } /*! - \fn static QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QSharedPointer ringBuffer) + \fn static QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(std::shared_ptr ringBuffer) Create a QNonContiguousByteDevice out of a QRingBuffer. \internal */ -QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QSharedPointer ringBuffer) +QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(std::shared_ptr ringBuffer) { return new QNonContiguousByteDeviceRingBufferImpl(ringBuffer); } /*! - Create a QNonContiguousByteDevice out of a QRingBuffer, return it in a QSharedPointer. + Create a QNonContiguousByteDevice out of a QRingBuffer, return it in a std::shared_ptr. \internal */ -QSharedPointer QNonContiguousByteDeviceFactory::createShared(QSharedPointer ringBuffer) +std::shared_ptr QNonContiguousByteDeviceFactory::createShared(std::shared_ptr ringBuffer) { - return QSharedPointer::create(std::move(ringBuffer)); + return std::make_shared(std::move(ringBuffer)); } /*! @@ -552,9 +551,9 @@ QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QByteArray *by \internal */ -QSharedPointer QNonContiguousByteDeviceFactory::createShared(QByteArray *byteArray) +std::shared_ptr QNonContiguousByteDeviceFactory::createShared(QByteArray *byteArray) { - return QSharedPointer::create(byteArray); + return std::make_shared(byteArray); } /*! diff --git a/src/corelib/io/qnoncontiguousbytedevice_p.h b/src/corelib/io/qnoncontiguousbytedevice_p.h index c570480d85b..94d8e5ef9c8 100644 --- a/src/corelib/io/qnoncontiguousbytedevice_p.h +++ b/src/corelib/io/qnoncontiguousbytedevice_p.h @@ -55,9 +55,10 @@ #include #include #include -#include #include "private/qringbuffer_p.h" +#include + QT_BEGIN_NAMESPACE class Q_CORE_EXPORT QNonContiguousByteDevice : public QObject @@ -85,13 +86,13 @@ class Q_CORE_EXPORT QNonContiguousByteDeviceFactory { public: static QNonContiguousByteDevice *create(QIODevice *device); - static QSharedPointer createShared(QIODevice *device); + static std::shared_ptr createShared(QIODevice *device); static QNonContiguousByteDevice *create(QByteArray *byteArray); - static QSharedPointer createShared(QByteArray *byteArray); + static std::shared_ptr createShared(QByteArray *byteArray); - static QNonContiguousByteDevice *create(QSharedPointer ringBuffer); - static QSharedPointer createShared(QSharedPointer ringBuffer); + static QNonContiguousByteDevice *create(std::shared_ptr ringBuffer); + static std::shared_ptr createShared(std::shared_ptr ringBuffer); static QIODevice *wrap(QNonContiguousByteDevice *byteDevice); }; @@ -119,7 +120,7 @@ protected: class QNonContiguousByteDeviceRingBufferImpl : public QNonContiguousByteDevice { public: - explicit QNonContiguousByteDeviceRingBufferImpl(QSharedPointer rb); + explicit QNonContiguousByteDeviceRingBufferImpl(std::shared_ptr rb); ~QNonContiguousByteDeviceRingBufferImpl(); const char *readPointer(qint64 maximumLength, qint64 &len) override; bool advanceReadPointer(qint64 amount) override; @@ -129,8 +130,8 @@ public: qint64 pos() const override; protected: - QSharedPointer ringBuffer; - qint64 currentPosition; + std::shared_ptr ringBuffer; + qint64 currentPosition = 0; }; class QNonContiguousByteDeviceIoDeviceImpl : public QNonContiguousByteDevice diff --git a/src/network/access/qnetworkaccessbackend.cpp b/src/network/access/qnetworkaccessbackend.cpp index f7e29340d95..2284461099b 100644 --- a/src/network/access/qnetworkaccessbackend.cpp +++ b/src/network/access/qnetworkaccessbackend.cpp @@ -80,7 +80,7 @@ public: QNetworkAccessBackend::TargetTypes m_targetTypes; QNetworkAccessBackend::SecurityFeatures m_securityFeatures; QNetworkAccessBackend::IOFeatures m_ioFeatures; - QSharedPointer uploadByteDevice; + std::shared_ptr uploadByteDevice; QIODevice *wrappedUploadByteDevice; QNetworkReplyImplPrivate *m_reply = nullptr; QNetworkAccessManagerPrivate *m_manager = nullptr; @@ -566,7 +566,7 @@ QIODevice *QNetworkAccessBackend::createUploadByteDevice() // We want signal emissions only for normal asynchronous uploads if (!isSynchronous()) { - connect(d->uploadByteDevice.data(), &QNonContiguousByteDevice::readProgress, this, + connect(d->uploadByteDevice.get(), &QNonContiguousByteDevice::readProgress, this, [this](qint64 a, qint64 b) { Q_D(QNetworkAccessBackend); if (!d->m_reply->isFinished) @@ -574,7 +574,7 @@ QIODevice *QNetworkAccessBackend::createUploadByteDevice() }); } - d->wrappedUploadByteDevice = QNonContiguousByteDeviceFactory::wrap(d->uploadByteDevice.data()); + d->wrappedUploadByteDevice = QNonContiguousByteDeviceFactory::wrap(d->uploadByteDevice.get()); return d->wrappedUploadByteDevice; } diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp index b68e82a5e12..e43b9dcb676 100644 --- a/src/network/access/qnetworkreplyhttpimpl.cpp +++ b/src/network/access/qnetworkreplyhttpimpl.cpp @@ -199,7 +199,7 @@ QNetworkReplyHttpImpl::QNetworkReplyHttpImpl(QNetworkAccessManager* const manage if (d->synchronous && outgoingData) { // The synchronous HTTP is a corner case, we will put all upload data in one big QByteArray in the outgoingDataBuffer. // Yes, this is not the most efficient thing to do, but on the other hand synchronous XHR needs to die anyway. - d->outgoingDataBuffer = QSharedPointer::create(); + d->outgoingDataBuffer = std::make_shared(); qint64 previousDataSize = 0; do { previousDataSize = d->outgoingDataBuffer->size(); @@ -923,14 +923,14 @@ void QNetworkReplyHttpImplPrivate::postRequest(const QNetworkRequest &newHttpReq delegate->httpRequest.setUploadByteDevice(forwardUploadDevice); // If the device in the user thread claims it has more data, keep the flow to HTTP thread going - QObject::connect(uploadByteDevice.data(), SIGNAL(readyRead()), + QObject::connect(uploadByteDevice.get(), SIGNAL(readyRead()), q, SLOT(uploadByteDeviceReadyReadSlot()), Qt::QueuedConnection); // From user thread to http thread: QObject::connect(q, SIGNAL(haveUploadData(qint64,QByteArray,bool,qint64)), forwardUploadDevice, SLOT(haveDataSlot(qint64,QByteArray,bool,qint64)), Qt::QueuedConnection); - QObject::connect(uploadByteDevice.data(), SIGNAL(readyRead()), + QObject::connect(uploadByteDevice.get(), SIGNAL(readyRead()), forwardUploadDevice, SIGNAL(readyRead()), Qt::QueuedConnection); @@ -953,7 +953,7 @@ void QNetworkReplyHttpImplPrivate::postRequest(const QNetworkRequest &newHttpReq // use the uploadByteDevice provided to us by the QNetworkReplyImpl. // The code that is in start() makes sure it is safe to use from a thread // since it only wraps a QRingBuffer - delegate->httpRequest.setUploadByteDevice(uploadByteDevice.data()); + delegate->httpRequest.setUploadByteDevice(uploadByteDevice.get()); } } @@ -1966,7 +1966,7 @@ void QNetworkReplyHttpImplPrivate::_q_bufferOutgoingData() if (!outgoingDataBuffer) { // first call, create our buffer - outgoingDataBuffer = QSharedPointer::create(); + outgoingDataBuffer = std::make_shared(); QObject::connect(outgoingData, SIGNAL(readyRead()), q, SLOT(_q_bufferOutgoingData())); QObject::connect(outgoingData, SIGNAL(readChannelFinished()), q, SLOT(_q_bufferOutgoingDataFinished())); @@ -2066,10 +2066,10 @@ QNonContiguousByteDevice* QNetworkReplyHttpImplPrivate::createUploadByteDevice() // We want signal emissions only for normal asynchronous uploads if (!synchronous) - QObject::connect(uploadByteDevice.data(), SIGNAL(readProgress(qint64,qint64)), + QObject::connect(uploadByteDevice.get(), SIGNAL(readProgress(qint64,qint64)), q, SLOT(emitReplyUploadProgress(qint64,qint64))); - return uploadByteDevice.data(); + return uploadByteDevice.get(); } void QNetworkReplyHttpImplPrivate::_q_finished() diff --git a/src/network/access/qnetworkreplyhttpimpl_p.h b/src/network/access/qnetworkreplyhttpimpl_p.h index 12fc484fe5c..8fb59cdd49d 100644 --- a/src/network/access/qnetworkreplyhttpimpl_p.h +++ b/src/network/access/qnetworkreplyhttpimpl_p.h @@ -75,6 +75,8 @@ Q_MOC_INCLUDE() #include +#include + QT_REQUIRE_CONFIG(http); QT_BEGIN_NAMESPACE @@ -197,11 +199,11 @@ public: // upload QNonContiguousByteDevice* createUploadByteDevice(); - QSharedPointer uploadByteDevice; + std::shared_ptr uploadByteDevice; qint64 uploadByteDevicePosition; bool uploadDeviceChoking; // if we couldn't readPointer() any data at the moment QIODevice *outgoingData; - QSharedPointer outgoingDataBuffer; + std::shared_ptr outgoingDataBuffer; void emitReplyUploadProgress(qint64 bytesSent, qint64 bytesTotal); // dup? void onRedirected(const QUrl &redirectUrl, int httpStatus, int maxRedirectsRemainig); void followRedirect(); diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp index 61745155f58..39729dd13aa 100644 --- a/src/network/access/qnetworkreplyimpl.cpp +++ b/src/network/access/qnetworkreplyimpl.cpp @@ -193,7 +193,7 @@ void QNetworkReplyImplPrivate::_q_bufferOutgoingData() if (!outgoingDataBuffer) { // first call, create our buffer - outgoingDataBuffer = QSharedPointer::create(); + outgoingDataBuffer = std::make_shared(); QObject::connect(outgoingData, SIGNAL(readyRead()), q, SLOT(_q_bufferOutgoingData())); QObject::connect(outgoingData, SIGNAL(readChannelFinished()), q, SLOT(_q_bufferOutgoingDataFinished())); @@ -249,7 +249,7 @@ void QNetworkReplyImplPrivate::setup(QNetworkAccessManager::Operation op, const // The synchronous HTTP is a corner case, we will put all upload data in one big QByteArray in the outgoingDataBuffer. // Yes, this is not the most efficient thing to do, but on the other hand synchronous XHR needs to die anyway. if (synchronousHttpAttribute.toBool() && outgoingData) { - outgoingDataBuffer = QSharedPointer::create(); + outgoingDataBuffer = std::make_shared(); qint64 previousDataSize = 0; do { previousDataSize = outgoingDataBuffer->size(); diff --git a/src/network/access/qnetworkreplyimpl_p.h b/src/network/access/qnetworkreplyimpl_p.h index 7d014f9173a..e390acb69d7 100644 --- a/src/network/access/qnetworkreplyimpl_p.h +++ b/src/network/access/qnetworkreplyimpl_p.h @@ -63,6 +63,8 @@ #include "private/qbytedata_p.h" #include +#include + QT_BEGIN_NAMESPACE class QAbstractNetworkCache; @@ -153,7 +155,7 @@ public: QNetworkAccessBackend *backend; QIODevice *outgoingData; - QSharedPointer outgoingDataBuffer; + std::shared_ptr outgoingDataBuffer; QIODevice *copyDevice; QAbstractNetworkCache *networkCache() const; diff --git a/src/network/access/qnetworkreplywasmimpl.cpp b/src/network/access/qnetworkreplywasmimpl.cpp index 2cae6847b8f..bbb41da9fb4 100644 --- a/src/network/access/qnetworkreplywasmimpl.cpp +++ b/src/network/access/qnetworkreplywasmimpl.cpp @@ -406,7 +406,7 @@ void QNetworkReplyWasmImplPrivate::_q_bufferOutgoingData() if (!outgoingDataBuffer) { // first call, create our buffer - outgoingDataBuffer = QSharedPointer::create(); + outgoingDataBuffer = std::make_shared(); QObject::connect(outgoingData, SIGNAL(readyRead()), q, SLOT(_q_bufferOutgoingData())); QObject::connect(outgoingData, SIGNAL(readChannelFinished()), q, SLOT(_q_bufferOutgoingDataFinished())); diff --git a/src/network/access/qnetworkreplywasmimpl_p.h b/src/network/access/qnetworkreplywasmimpl_p.h index db9fd5657e3..407890d8378 100644 --- a/src/network/access/qnetworkreplywasmimpl_p.h +++ b/src/network/access/qnetworkreplywasmimpl_p.h @@ -63,6 +63,8 @@ #include #include +#include + QT_BEGIN_NAMESPACE class QIODevice; @@ -134,7 +136,7 @@ public: QByteArray downloadBuffer; QIODevice *outgoingData; - QSharedPointer outgoingDataBuffer; + std::shared_ptr outgoingDataBuffer; QByteArray requestData; static void downloadProgress(emscripten_fetch_t *fetch);