Details
-
Suggestion
-
Resolution: Done
-
P3: Somewhat important
-
5.0.0
-
None
-
0b8065b5819efd8ba3741ea5703d5b95954b16c2
Description
The documentation of the QSqlDatabase destructor states:
"Destroys the object and frees any allocated resources.
If this is the last QSqlDatabase object that uses a certain database connection, the database connection is automatically closed."
This lead me to the impression that if I aquire a QSqlDatabase object by the static ::database() call (or by ::addDatabase()) and the object subsequently goes out of scope the connection would be closed. See the attached zip file for an example. All aquired QSqlDatabase objects are stack local and go out of scope. Contrary to my expectations the connection is not closed and reopened though.
After rereading the documentation of the ::addDatabase() call it slowly dawned on me that there is another QSqlDatabase object stored implicitly. This is made somewhat implicit by the wording of the documentation. Here the term "database connection" is used, while in the destructor docs the term "QSqlDatabase object" is used.
The documentation could be updated to clarify this. I would be willing to contribute a documentation patch if it is agreed upon that this is a real issue.