diff options
author | Giuseppe D'Angelo <[email protected]> | 2025-01-13 14:17:29 +0100 |
---|---|---|
committer | Giuseppe D'Angelo <[email protected]> | 2025-02-03 20:54:56 +0100 |
commit | f744cef06cf3a56591782f487c545b55b2a673fb (patch) | |
tree | f130190e8e35a5dc4cb7b715eca3bef7276bb2ee /src/sql/kernel/qsqlquery.h | |
parent | c0e96e0c8b2e9b39920597261a45683136d8483e (diff) |
QSqlQuery: complete the deprecation/removal of its copies
QSqlQuery has been made movable in Qt 6.2
(14f9f00fdb2dc428610c08e3d9d03e38e9602166). The pre-existing copy
operations have been deprecated, but not removed, in order to preserve
SC/BC.
This left us with two issues:
1) Whether or not to keep the deprecated copies in Qt 7. The answer is
no: the copy operations are impossible to implement in a way consistent
with value semantics (the state of the DB driver can't be copied in
general). Therefore, mark the related APIs as to-be-removed, and not
just deprecated.
2) While we no longer copy QSqlQuery from Qt code directly, QMetaType
still detects the presence of the copy constructor and extracts it,
triggering the deprecation warning.
Rather than unconditionally suppressing the warning (which will hide any
similar issue we might have in the future), add a local workaround that
raises a runtime warning if QSqlQuery is copied through QMetaType, while
not raising the deprecation warning when building Qt itself.
[ChangeLog][QtSql][QSqlQuery] Copying a QSqlQuery object via QMetaType
now raises a runtime warning. Note that copy operations for QSqlQuery
objects have already been deprecated since Qt 6.2, and are planned to be
removed in Qt 7.
Fixes: QTBUG-132752
Task-number: QTBUG-91766
Pick-to: 6.9
Change-Id: I48714ad53ec706a5e4e055c45a1c05f372382940
Reviewed-by: Marc Mutz <[email protected]>
Diffstat (limited to 'src/sql/kernel/qsqlquery.h')
-rw-r--r-- | src/sql/kernel/qsqlquery.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/sql/kernel/qsqlquery.h b/src/sql/kernel/qsqlquery.h index 96ad9022127..ec5f06550e1 100644 --- a/src/sql/kernel/qsqlquery.h +++ b/src/sql/kernel/qsqlquery.h @@ -32,7 +32,7 @@ public: explicit QSqlQuery(const QString& query = QString(), const QSqlDatabase &db = QSqlDatabase()); explicit QSqlQuery(const QSqlDatabase &db); -#if QT_DEPRECATED_SINCE(6, 2) +#if QT_REMOVAL_QT7_DEPRECATED_SINCE(6, 2) QT_DEPRECATED_VERSION_X_6_2("QSqlQuery is not meant to be copied. Use move construction instead.") QSqlQuery(const QSqlQuery &other); QT_DEPRECATED_VERSION_X_6_2("QSqlQuery is not meant to be copied. Use move assignment instead.") @@ -111,6 +111,10 @@ public: void finish(); bool nextResult(); +#if QT_REMOVAL_QT7_DEPRECATED_SINCE(6, 2) + // Avoid raising warnings in QMetaType, cf. QTBUG-132752 + using _q_hasDeprecatedCopyConstructor = void; +#endif private: QSqlQueryPrivate* d; }; |