QSslError: port to unique_ptr

So to avoid QScopedPointer::swap deprecation. Side note,
QSslError is not implictly shared (although it should be, but
that's a job for Qt 7).

Change-Id: I42f7abffa81d72aac5af157074a0c3cbd20ba253
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Giuseppe D'Angelo 2021-03-11 19:27:53 +01:00
parent faa6f19b2a
commit 4f4d7de499
2 changed files with 11 additions and 3 deletions

View File

@ -111,6 +111,11 @@
QT_BEGIN_NAMESPACE
#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
// Avoid an ABI break due to the QScopedPointer->std::unique_ptr change
static_assert(sizeof(QScopedPointer<QSslErrorPrivate>) == sizeof(std::unique_ptr<QSslErrorPrivate>));
#endif
class QSslErrorPrivate
{
public:
@ -163,7 +168,7 @@ QSslError::QSslError(SslError error, const QSslCertificate &certificate)
QSslError::QSslError(const QSslError &other)
: d(new QSslErrorPrivate)
{
*d.data() = *other.d.data();
*d.get() = *other.d.get();
}
/*!
@ -180,7 +185,7 @@ QSslError::~QSslError()
*/
QSslError &QSslError::operator=(const QSslError &other)
{
*d.data() = *other.d.data();
*d.get() = *other.d.get();
return *this;
}

View File

@ -45,6 +45,8 @@
#include <QtCore/qvariant.h>
#include <QtNetwork/qsslcertificate.h>
#include <memory>
QT_BEGIN_NAMESPACE
@ -120,7 +122,8 @@ public:
QSslCertificate certificate() const;
private:
QScopedPointer<QSslErrorPrivate> d;
// ### Qt 7: make QSslError implicitly shared
std::unique_ptr<QSslErrorPrivate> d;
};
Q_DECLARE_SHARED(QSslError)