From f081578ce097e5b437a0b1beee84f7056e9099f8 Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Mon, 21 Aug 2023 17:06:02 +0200 Subject: [PATCH] QSqlIndex: implement member swap() and use a macro for move-assignment Also declare the type as shared using Q_DECLARE_SHARED Found during Qt 6.6 API review. This commit amends 46e909a37a38289a601333ae6f205e8946152287. [ChangeLog][QtSql] QSqlIndex is now a relocatable type. Pick-to: 6.6 Change-Id: I78394cba082b4df2e4d8a6aab8e8e87f2340962c Reviewed-by: Marc Mutz --- src/sql/kernel/qsqlindex.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/sql/kernel/qsqlindex.h b/src/sql/kernel/qsqlindex.h index 67eeb2a9e0..f011e64353 100644 --- a/src/sql/kernel/qsqlindex.h +++ b/src/sql/kernel/qsqlindex.h @@ -20,7 +20,14 @@ public: QSqlIndex(QSqlIndex &&other) noexcept = default; ~QSqlIndex(); QSqlIndex &operator=(const QSqlIndex &other); - QSqlIndex &operator=(QSqlIndex &&other) = default; + QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QSqlIndex) + + void swap(QSqlIndex &other) noexcept { + QSqlRecord::swap(other); + cursor.swap(other.cursor); + nm.swap(other.nm); + sorts.swap(other.sorts); + }; void setCursorName(const QString &cursorName); inline QString cursorName() const { return cursor; } @@ -41,6 +48,8 @@ private: QList sorts; }; +Q_DECLARE_SHARED(QSqlIndex) + QT_END_NAMESPACE #endif // QSQLINDEX_H