Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-24445

when calling QSqlDatabase::open() multiple times, sqlite driver creates multiple file handles, which are leaked

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Not Evaluated
    • None
    • 4.8.0
    • SQL Support
    • None
    • Windows 7 64bit, QT 4.8.0, toolchain x86_64_win32-msvc2010 (Microsoft Visual C++ Compiler 10.0 (x64))

    Description

      In one part of my application I create a QSqlDatabase object, open the database connection and fill the database.
      Afterwards, two other program parts fetch the QSqlDatabase object from the global connection store, create queries and forward those queries to QSqlQueryModel based models.

      Now to be sure that the database is open, I explicitly call QSqlDatabase::open() in both program parts, without checking whether the the connection might already be open - the documentation for QSqlDatabase::open() doesn't state that one shouldn't call it multiple times, so this seems to be legitimate.

      However, the third call to QSqlDatabase::open() opens a new file handle behind the scenes when a valid and active QSqlQuery exists. This file handle is leaked even when the queries along with the models are properly destroyed.

      Attached you find a simple unit test exposing the problem - it should fail on line 94.

      Note that this bug might be related to QTBUG-16967 and QTBUG-19056, but doesn't seem to be a duplicate.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            zhongle honglei zhang
            triendl.kj klaus triendl
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes