diff options
Diffstat (limited to 'src/sql/kernel/qsqlerror.cpp')
-rw-r--r-- | src/sql/kernel/qsqlerror.cpp | 47 |
1 files changed, 19 insertions, 28 deletions
diff --git a/src/sql/kernel/qsqlerror.cpp b/src/sql/kernel/qsqlerror.cpp index 7f56357c10..a52f209d53 100644 --- a/src/sql/kernel/qsqlerror.cpp +++ b/src/sql/kernel/qsqlerror.cpp @@ -19,7 +19,7 @@ QDebug operator<<(QDebug dbg, const QSqlError &s) } #endif -class QSqlErrorPrivate +class QSqlErrorPrivate : public QSharedData { public: QString driverError; @@ -27,7 +27,7 @@ public: QSqlError::ErrorType errorType; QString errorCode; }; - +QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QSqlErrorPrivate) /*! \class QSqlError @@ -103,45 +103,38 @@ QSqlError::QSqlError(const QString &driverText, const QString &databaseText, /*! Creates a copy of \a other. */ -QSqlError::QSqlError(const QSqlError& other) - : d(new QSqlErrorPrivate(*other.d)) -{ -} +QSqlError::QSqlError(const QSqlError &other) + = default; /*! Assigns the \a other error's values to this error. */ -QSqlError& QSqlError::operator=(const QSqlError& other) -{ - if (&other == this) - return *this; - if (d && other.d) - *d = *other.d; - else if (d) - *d = QSqlErrorPrivate(); - else if (other.d) - d = new QSqlErrorPrivate(*other.d); - return *this; -} +QSqlError &QSqlError::operator=(const QSqlError &other) + = default; + /*! - Compare the \a other error's values to this error and returns \c true, if it equal. + Compare the \a other error's type() and nativeErrorCode() + to this error and returns \c true, if it equal. */ -bool QSqlError::operator==(const QSqlError& other) const +bool QSqlError::operator==(const QSqlError &other) const { - return (d->errorType == other.d->errorType); + return (d->errorType == other.d->errorType && + d->errorCode == other.d->errorCode); } /*! - Compare the \a other error's values to this error and returns \c true if it is not equal. + Compare the \a other error's type() and nativeErrorCode() + to this error and returns \c true if it is not equal. */ -bool QSqlError::operator!=(const QSqlError& other) const +bool QSqlError::operator!=(const QSqlError &other) const { - return (d->errorType != other.d->errorType); + return (d->errorType != other.d->errorType || + d->errorCode != other.d->errorCode); } @@ -150,9 +143,7 @@ bool QSqlError::operator!=(const QSqlError& other) const */ QSqlError::~QSqlError() -{ - delete d; -} + = default; /*! Returns the text of the error as reported by the driver. This may @@ -209,7 +200,7 @@ QString QSqlError::nativeErrorCode() const QString QSqlError::text() const { QString result = d->databaseError; - if (!d->databaseError.isEmpty() && !d->driverError.isEmpty() && !d->databaseError.endsWith("\n"_L1)) + if (!d->databaseError.isEmpty() && !d->driverError.isEmpty() && !d->databaseError.endsWith(u'\n')) result += u' '; result += d->driverError; return result; |