Details
-
Bug
-
Resolution: Duplicate
-
Not Evaluated
-
None
-
4.6.2
-
None
-
only apparent on windows because of locking. suspected on others
Description
With sqlite if you create queries and do not free/destroy those queries by a explicit delete or let them pass out of scope before closing the database connection Qt leaves a the database file open and locked even after the close. If the query is freed after the query is closed the file is still left open and locked. On windows the database file cannot be removed while still open which makes unit tests that create temporary database files unremovable in the same program if queries are not destroyed before closing.
The documentation for QSqlDatabase::close() states "Closes the database connection, freeing any resources acquired, and invalidating any existing QSqlQuery objects that are used with the database."
Note that at least calling QSqlQuery::finish() does not alleviate the described problem. My memory is that QSqlQuery::clear() is similarly ineffective but I could be wrong.
It would seem that either the documentation needs to be changed to explicitly say that QSqlQuery's must be freed before closing or a bug exists in the Sqlite driver.
I have seen at least one forum post of the same issue. The poster resolved his issue by switching to a in memory database for his unit test. This is more of a work around than a fix though.
Thanks!
Attachments
Issue Links
- is replaced by
-
QTBUG-16967 sqlite driver eats/leaks memory (QTBUG-11210 clone)
- Closed