From 7fa938754ad897bdefc97db9604af91533e86433 Mon Sep 17 00:00:00 2001 From: Mate Barany Date: Tue, 2 Jul 2024 13:55:01 +0200 Subject: [PATCH] Add move constructor to QHostAddress 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: I301e8e3f275b0d5217afc1559947870ff87bcf45 Reviewed-by: Thiago Macieira Reviewed-by: Marc Mutz (cherry picked from commit 1caee12b1ac8cef3aabd8d2e319c88a84c64c585) Reviewed-by: Qt Cherry-pick Bot --- src/network/kernel/qhostaddress.cpp | 14 ++++++++++++++ src/network/kernel/qhostaddress.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp index 0330fb091b..d6e0b38462 100644 --- a/src/network/kernel/qhostaddress.cpp +++ b/src/network/kernel/qhostaddress.cpp @@ -34,6 +34,8 @@ QHostAddressPrivate::QHostAddressPrivate() memset(&a6, 0, sizeof(a6)); } +QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QHostAddressPrivate) + void QHostAddressPrivate::setAddress(quint32 a_) { a = a_; @@ -449,6 +451,18 @@ QHostAddress::QHostAddress(const QHostAddress &address) { } +/*! + \fn QHostAddress::QHostAddress(QHostAddress &&other) + + \since 6.8 + + Move-constructs a new QHostAddress from \a other. + + \note The moved-from object \a other is placed in a partially-formed state, + in which the only valid operations are destruction and assignment of a new + value. +*/ + /*! Constructs a QHostAddress object for \a address. */ diff --git a/src/network/kernel/qhostaddress.h b/src/network/kernel/qhostaddress.h index 6aa045c959..3c77c2111b 100644 --- a/src/network/kernel/qhostaddress.h +++ b/src/network/kernel/qhostaddress.h @@ -19,6 +19,7 @@ QT_BEGIN_NAMESPACE class QHostAddressPrivate; +QT_DECLARE_QESDP_SPECIALIZATION_DTOR(QHostAddressPrivate) class QT6_ONLY(Q_NETWORK_EXPORT) QIPv6Address { @@ -81,6 +82,7 @@ public: explicit QHostAddress(const sockaddr *address); explicit QHostAddress(const QString &address); QHostAddress(const QHostAddress ©); + QHostAddress(QHostAddress &&other) noexcept = default; QHostAddress(SpecialAddress address); ~QHostAddress();