diff options
author | Christian Ehrlicher <[email protected]> | 2023-04-12 21:40:02 +0200 |
---|---|---|
committer | Marc Mutz <[email protected]> | 2023-04-26 19:56:07 +0000 |
commit | 1f27dc68717daf22ba5dab4634c60eda3eadab9c (patch) | |
tree | ed5735b16654cca51f75c2186fc3a459d953e9e3 /src/sql/kernel/qsqlfield.cpp | |
parent | 204f1764ca6f4b670eaa87a775ded09a72a07aba (diff) |
QSqlField: add move ctor & move operator
Add the move ctor and move operator for QSqlField
Task-number: QTBUG-109938
Change-Id: Ib66eff76c3a920de9cfb3288f4219555005e7ae5
Reviewed-by: Marc Mutz <[email protected]>
Diffstat (limited to 'src/sql/kernel/qsqlfield.cpp')
-rw-r--r-- | src/sql/kernel/qsqlfield.cpp | 42 |
1 files changed, 7 insertions, 35 deletions
diff --git a/src/sql/kernel/qsqlfield.cpp b/src/sql/kernel/qsqlfield.cpp index c407137e7e9..9fdb24f3306 100644 --- a/src/sql/kernel/qsqlfield.cpp +++ b/src/sql/kernel/qsqlfield.cpp @@ -2,36 +2,20 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qsqlfield.h" -#include "qatomic.h" #include "qdebug.h" QT_BEGIN_NAMESPACE -class QSqlFieldPrivate +class QSqlFieldPrivate : public QSharedData { public: QSqlFieldPrivate(const QString &name, QMetaType type, const QString &tableName) : - ref(1), nm(name), table(tableName), def(QVariant()), type(type), + nm(name), table(tableName), def(QVariant()), type(type), req(QSqlField::Unknown), len(-1), prec(-1), tp(-1), ro(false), gen(true), autoval(false) {} - QSqlFieldPrivate(const QSqlFieldPrivate &other) - : ref(1), - nm(other.nm), - table(other.table), - def(other.def), - type(other.type), - req(other.req), - len(other.len), - prec(other.prec), - tp(other.tp), - ro(other.ro), - gen(other.gen), - autoval(other.autoval) - {} - bool operator==(const QSqlFieldPrivate& other) const { return (nm == other.nm @@ -46,7 +30,6 @@ public: && autoval == other.autoval); } - QAtomicInt ref; QString nm; QString table; QVariant def; @@ -59,6 +42,7 @@ public: bool gen: 1; bool autoval: 1; }; +QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QSqlFieldPrivate) /*! @@ -151,23 +135,14 @@ QSqlField::QSqlField(const QString &fieldName, QMetaType type, const QString &ta */ QSqlField::QSqlField(const QSqlField &other) - : val(other.val), - d(other.d) -{ - d->ref.ref(); -} + = default; /*! Sets the field equal to \a other. */ QSqlField& QSqlField::operator=(const QSqlField& other) -{ - qAtomicAssign(d, other.d); - val = other.val; - return *this; -} - + = default; /*! \fn bool QSqlField::operator!=(const QSqlField &other) const Returns \c true if the field is unequal to \a other; otherwise returns @@ -189,10 +164,7 @@ bool QSqlField::operator==(const QSqlField& other) const */ QSqlField::~QSqlField() -{ - if (!d->ref.deref()) - delete d; -} + = default; /*! Sets the required status of this field to \a required. @@ -426,7 +398,7 @@ bool QSqlField::isNull() const */ void QSqlField::detach() { - qAtomicDetach(d); + d.detach(); } /*! |