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

[CRASH] QSortFilterProxyModel crash

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 4.6.0
    • 4.5.2
    • Widgets: Itemviews
    • None
    • 2d750192e73244f5b4ad6b451f264728d42669be

    Description

      Steps to reproduce / test case:

      If you set as a source model a QSqlQueryModel which has no query set yet (or any other empty model, I assume), and then use setHeaderData() on the source model, the application crashes.

      Example code:

      #include <QApplication>
      #include <QSqlQueryModel>
      #include <QSortFilterProxyModel>

      // connection.h from Qt/examples/sql
      #include "../connection.h"

      int main(int argc, char *argv[])
      {
      QApplication app(argc, argv);
      if (!createConnection())
      return 1;

      QSqlQueryModel plainModel;
      QSortFilterProxyModel proxyModel;
      proxyModel.setSourceModel(&plainModel);

      // next line causes the crash
      plainModel.setHeaderData(0, Qt::Horizontal, QObject::tr("ID"));

      // setting the query before the header data works...
      plainModel.setQuery("select * from person");
      plainModel.setHeaderData(0, Qt::Horizontal, QObject::tr("ID"));

      return 0;
      }

      More information:

      The attached image shows where the crash occurs. No validation is done before accessing the vector.

      Attachments

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

        Activity

          People

            dedietri Gabriel de Dietrich (drgvond)
            sthomass Stian Sandvik Thomassen (closed Nokia identity) (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes