Priority: Not Evaluated
Affects Version/s: 4.6.2
Fix Version/s: None
Component/s: Qt SQL
only apparent on windows because of locking. suspected on others
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.