From 45b7af038f87015bb00660af7b71c28ce6af4fd8 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Sat, 13 Mar 2021 00:06:16 +0100 Subject: [PATCH] Port from QScopedPointer to std::unique_ptr MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Silence compiler warnings from deprecated QScopedPointer::swap after fe9d7bf759d116f99131d14ac8b1fb44b2bc62fd. For Qt 7, both QSslCipher and QNetworkAddressEntry should be made into implicitly shared classes. Change-Id: Idfd5ec4b5a0f156f212d57684822a3cd1d88de1a Reviewed-by: Qt CI Bot Reviewed-by: MÃ¥rten Nordheim --- src/network/kernel/qnetworkinterface.cpp | 7 +++++-- src/network/kernel/qnetworkinterface.h | 5 ++++- src/network/ssl/qsslcipher.cpp | 7 +++++-- src/network/ssl/qsslcipher.h | 5 ++++- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/network/kernel/qnetworkinterface.cpp b/src/network/kernel/qnetworkinterface.cpp index 6e87a783a8..b8ba9fcd07 100644 --- a/src/network/kernel/qnetworkinterface.cpp +++ b/src/network/kernel/qnetworkinterface.cpp @@ -49,6 +49,9 @@ QT_BEGIN_NAMESPACE +static_assert(QT_VERSION < QT_VERSION_CHECK(7, 0, 0) + && sizeof(QScopedPointer) == sizeof(std::unique_ptr)); + static QList postProcess(QList list) { // Some platforms report a netmask but don't report a broadcast address @@ -204,7 +207,7 @@ QNetworkAddressEntry::QNetworkAddressEntry() object \a other. */ QNetworkAddressEntry::QNetworkAddressEntry(const QNetworkAddressEntry &other) - : d(new QNetworkAddressEntryPrivate(*other.d.data())) + : d(new QNetworkAddressEntryPrivate(*other.d.get())) { } @@ -213,7 +216,7 @@ QNetworkAddressEntry::QNetworkAddressEntry(const QNetworkAddressEntry &other) */ QNetworkAddressEntry &QNetworkAddressEntry::operator=(const QNetworkAddressEntry &other) { - *d.data() = *other.d.data(); + *d.get() = *other.d.get(); return *this; } diff --git a/src/network/kernel/qnetworkinterface.h b/src/network/kernel/qnetworkinterface.h index c65ea58860..b96ca0e5fa 100644 --- a/src/network/kernel/qnetworkinterface.h +++ b/src/network/kernel/qnetworkinterface.h @@ -45,6 +45,8 @@ #include #include +#include + #ifndef QT_NO_NETWORKINTERFACE QT_BEGIN_NAMESPACE @@ -96,7 +98,8 @@ public: bool isTemporary() const { return !isPermanent(); } private: - QScopedPointer d; + // ### Qt 7: make implicitly shared + std::unique_ptr d; }; Q_DECLARE_SHARED(QNetworkAddressEntry) diff --git a/src/network/ssl/qsslcipher.cpp b/src/network/ssl/qsslcipher.cpp index 738d521a38..2534072807 100644 --- a/src/network/ssl/qsslcipher.cpp +++ b/src/network/ssl/qsslcipher.cpp @@ -68,6 +68,9 @@ QT_BEGIN_NAMESPACE +static_assert(QT_VERSION < QT_VERSION_CHECK(7, 0, 0) + && sizeof(QScopedPointer) == sizeof(std::unique_ptr)); + /*! Constructs an empty QSslCipher object. */ @@ -127,7 +130,7 @@ QSslCipher::QSslCipher(const QString &name, QSsl::SslProtocol protocol) QSslCipher::QSslCipher(const QSslCipher &other) : d(new QSslCipherPrivate) { - *d.data() = *other.d.data(); + *d.get() = *other.d.get(); } /*! @@ -143,7 +146,7 @@ QSslCipher::~QSslCipher() */ QSslCipher &QSslCipher::operator=(const QSslCipher &other) { - *d.data() = *other.d.data(); + *d.get() = *other.d.get(); return *this; } diff --git a/src/network/ssl/qsslcipher.h b/src/network/ssl/qsslcipher.h index 6994f590ae..05692aca16 100644 --- a/src/network/ssl/qsslcipher.h +++ b/src/network/ssl/qsslcipher.h @@ -46,6 +46,8 @@ #include #include +#include + QT_BEGIN_NAMESPACE @@ -81,7 +83,8 @@ public: QSsl::SslProtocol protocol() const; private: - QScopedPointer d; + // ### Qt 7: make implicitly shared + std::unique_ptr d; friend class QSslSocketBackendPrivate; };