Skip to content

Port away from deprecated QSqlQuery copy constructor

Daniel Vrátil requested to merge work/dvratil/qsqlquery-move-only into master

QSqlQuery should be move-only. This is mostly OK, as most of our code was used to obtain a copy from the QueryBuilder and then discard the QueryBuilder. Instead we now get a reference to the instance owned by the QueryBuilder and keep the query builder around for as long as we need the QSqlQuery. This has a nice side-effect that I could remove explicit calls to QSqlQuery::finish() in most places and we instead call it in the QueryBuilder destructor, since it rarely lives much longer than necessary.

The only problem was the QueryCache, which relied on handing our copies of the original QSqlQuery. But the cache is per-thread and we should never have two overlapping identical querties in a single thread, so this change modifies the cache move the query to the caller (QueryBuilder) and forget about it, and the QueryBuilder will insert the query back into the cache once it is done with it. This also retains the LRU nature of the cache.

Finally, this change restructures, cleans up and modernizes the QueryBuilderTest, with each test data being scoped and not reusing QueryBuilders, bind values or anything else from previous test data.

Finally, thanks to this change, we can compile Akonadi with QT_DISABLE_DEPRECATED_BEFORE 6.2.

Merge request reports