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

App crash when using QSqlQueryModel with QSqlQuery as prepared statement

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 5.14.0 Alpha
    • 5.2.0
    • SQL Support
    • None
    • Qt 5.2.1, Qt Visual Studio Addin 1.2.2 , Visual Studio 2010, Win7.
    • All
    • e2431b619da5c53d34df0b46105deb4450ed0c1f (qt/qtbase/5.14)

    Description

      I am developing an application using Qt Visual Studio Addin 1.2.2 on Visual Studio 2010. OS is Win7.
      I got stuck with a problem. I described it here: http://stackoverflow.com/questions/25660089/qsqlquerymodel-with-a-parent-app-crash, but here's a sumup:

      I have a searchDock : public QDockWidget class. It has a QSqlQueryModel* model field. I initialize the model in searchDock constructor:
      model = new QSqlQueryModel(this);
      Then - the model uses QSqlQuery query, that I prepare with a `QSqlQuery::prepare` method. I execute the query, and pass it to the model :

      query.prepare(...);
      query.addBindValue(searchString); 
      
      if (!query.exec()) {
      	qDebug() << query.lastError();
      	return;
      }
      model->setQuery(query);
      

      And then I pass he model to a TableView:

      ui.kontrahenciList->setModel(model);
      ui.kontrahenciList->show();
      

      It all works as far. The problem is, that when I close the application, I get an error:

      Unhandled exception at 0x0f0c9f9a (qsqlpsqld.dll) in HurBudClientGUI.exe: 0xC0000005: Access violation reading location 0x00000004.

      I do not delete anything manually anywhere .
      Here's the call stack:

      > qsqlpsqld.dll!QScopedPointer<QObjectData,QScopedPointerDeleter<QObjectData> >::data() Line 143 + 0x3 bytes C++
      qsqlpsqld.dll!qGetPtrHelper<QScopedPointer<QObjectData,QScopedPointerDeleter<QObjectData> > >(const QScopedPointer<QObjectData,QScopedPointerDeleter<QObjectData> > & p) Line 919 + 0xb bytes C++
      qsqlpsqld.dll!QPSQLDriver::d_func() Line 106 + 0x13 bytes C++
      qsqlpsqld.dll!QPSQLResultPrivate::privDriver() Line 212 C++
      qsqlpsqld.dll!QPSQLResultPrivate::deallocatePreparedStmt() Line 306 + 0xc bytes C++
      qsqlpsqld.dll!QPSQLResult::~QPSQLResult() Line 328 C++
      qsqlpsqld.dll!QPSQLResult::`scalar deleting destructor'() + 0xf bytes C++
      Qt5Sqld.dll!QSqlQueryPrivate::~QSqlQueryPrivate() Line 94 + 0x23 bytes C++
      Qt5Sqld.dll!QSqlQueryPrivate::`scalar deleting destructor'() + 0xf bytes C++
      Qt5Sqld.dll!QSqlQuery::~QSqlQuery() Line 245 + 0x1e bytes C++
      Qt5Sqld.dll!QSqlQueryModelPrivate::~QSqlQueryModelPrivate() Line 90 + 0x3d bytes C++
      Qt5Sqld.dll!QSqlQueryModelPrivate::`scalar deleting destructor'() + 0xf bytes C++
      Qt5Cored.dll!6703bf06()
      [Frames below may be incorrect and/or missing, no symbols loaded for Qt5Cored.dll]
      Qt5Cored.dll!6703b92a()
      Qt5Cored.dll!670303f4()
      Qt5Cored.dll!66f70dc4()
      Qt5Cored.dll!66f73608()
      Qt5Sqld.dll!QSqlQueryModel::~QSqlQueryModel() Line 175 + 0x9 bytes C++
      HurBudClientGUI.exe!QSqlQueryModel::`scalar deleting destructor'() + 0x10 bytes C++
      Qt5Cored.dll!67031929()
      Qt5Widgetsd.dll!QWidget::~QWidget() Line 1488 C++
      Qt5Widgetsd.dll!QDockWidget::~QDockWidget() Line 1172 + 0x22 bytes C++
      HurBudClientGUI.exe!searchDock::~searchDock() Line 40 + 0x1c bytes C++
      HurBudClientGUI.exe!HurBudClientGUI::~HurBudClientGUI() Line 35 + 0x12 bytes C++
      HurBudClientGUI.exe!main(int argc, char * * argv) Line 23 + 0x1b bytes C++
      HurBudClientGUI.exe!WinMain(HINSTANCE__ * instance, HINSTANCE__ * prevInstance, char * __formal, int cmdShow) Line 131 + 0x12 bytes C++
      HurBudClientGUI.exe!__tmainCRTStartup() Line 547 + 0x2c bytes C
      HurBudClientGUI.exe!WinMainCRTStartup() Line 371 C
      kernel32.dll!75e9338a()
      ntdll.dll!76f79f72()
      ntdll.dll!76f79f45()

      The problem doesn't occur when I use "plain" QSqlQuery (without prepared statement). The problem also occurs, when I initialize the model without a parent, but delete it in the searchDock desctructor.

      I couldn't find any solution to this strange behaviour, so I think it's a bug

      Attachments

        1. dbtestgui.cpp
          1.0 kB
        2. dbtestgui.h
          0.3 kB
        3. main.cpp
          0.2 kB
        4. qtbug_43889.tgz
          1 kB
        5. testtab.sql
          0.3 kB

        Issue Links

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

          Activity

            People

              chehrlic Christian Ehrlicher
              murison Michał Mulawa
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes