From 8b2ff809f6c5330c51a3d14d4190336ee98cd399 Mon Sep 17 00:00:00 2001 From: Mate Barany Date: Tue, 2 Jul 2024 15:36:51 +0200 Subject: [PATCH] Add move constructor to QSslCertificate The class has a move assignment operator, it should have a move constructor as well. Found by an Axivion scan. Task-number: QTBUG-125026 Change-Id: I71fe066a84baede3a8cd309977a4a73d849dcfd1 Reviewed-by: Marc Mutz (cherry picked from commit 488362257d668760eb7bb60eb860570bd8b70d4d) Reviewed-by: Qt Cherry-pick Bot --- src/network/ssl/qsslcertificate.cpp | 14 ++++++++++++++ src/network/ssl/qsslcertificate.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/src/network/ssl/qsslcertificate.cpp b/src/network/ssl/qsslcertificate.cpp index a424bfd1b94..eff6c3a142b 100644 --- a/src/network/ssl/qsslcertificate.cpp +++ b/src/network/ssl/qsslcertificate.cpp @@ -134,6 +134,8 @@ QSslCertificatePrivate::QSslCertificatePrivate() QSslCertificatePrivate::~QSslCertificatePrivate() = default; +QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QSslCertificatePrivate) + /*! Constructs a QSslCertificate by reading \a format encoded data from \a device and using the first certificate found. You can @@ -198,6 +200,18 @@ QSslCertificate::QSslCertificate(const QSslCertificate &other) : d(other.d) { } +/*! + \fn QSslCertificate::QSslCertificate(QSslCertificate &&other) + + \since 6.8 + + Move-constructs a new QSslCertificate from \a other. + + \note The moved-from object \a other is placed in a partially-formed state, + in which the only valid operations are destructions and assignment of a new + value. +*/ + /*! Destroys the QSslCertificate. */ diff --git a/src/network/ssl/qsslcertificate.h b/src/network/ssl/qsslcertificate.h index cdf11b28b07..e34fa4d92a3 100644 --- a/src/network/ssl/qsslcertificate.h +++ b/src/network/ssl/qsslcertificate.h @@ -31,6 +31,8 @@ class QSslCertificate; Q_NETWORK_EXPORT size_t qHash(const QSslCertificate &key, size_t seed = 0) noexcept; class QSslCertificatePrivate; +QT_DECLARE_QESDP_SPECIALIZATION_DTOR(QSslCertificatePrivate) + class Q_NETWORK_EXPORT QSslCertificate { public: @@ -56,6 +58,7 @@ public: explicit QSslCertificate(QIODevice *device, QSsl::EncodingFormat format = QSsl::Pem); explicit QSslCertificate(const QByteArray &data = QByteArray(), QSsl::EncodingFormat format = QSsl::Pem); QSslCertificate(const QSslCertificate &other); + QSslCertificate(QSslCertificate &&other) noexcept = default; ~QSslCertificate(); QSslCertificate &operator=(QSslCertificate &&other) noexcept { swap(other); return *this; } QSslCertificate &operator=(const QSslCertificate &other);