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

HorizontalHeaderView & VerticalHeaderView does not disconnect from QQmlTableModel::headerDataChanged and can crash app

    XMLWordPrintable

Details

    • Linux/X11
    • 6b4939df5 (dev), d71ed94e2 (6.5), 8e4065ad3 (tqtc/lts-6.2), 2ff14d18c (tqtc/lts-5.15)

    Description

      If to TableModel connect/disconnect TableView with HorizontalHeaderView and/or VerticalHeaderView the QQmlTableModel::headerDataChanged signal will not be disconnected from TableVievs (even if TableView will be destroyed).

      In app what I develop it crash after several minutes of using the app. I can not reproduce crash in demo app. Image below is crash from the app:

      How to reproduce (connections leak not crash):

      1. Build and run attached HeaderViewsConnectionsLeak project.
      2. On application press several times Reload button.
      3. On Application Output you can see more and more connections to signal:
        signal: headerDataChanged(Qt::Orientation,int,int)
        <functor or function pointer>
        ...
        SIGNALS IN
        <-- QQmlTableModel::unnamed <unknown>

      Root cause:

      The root cause is in qquickheaderview.cpp
      Connect to &QAbstractItemModel::headerDataChanged is implemented as lambda but disconnect only from class instance:

       

      // 
      void QHeaderDataProxyModel::connectToModel()
      {
          if (m_model.isNull())
              return;
          connect(m_model, &QAbstractItemModel::headerDataChanged,
              [this](Qt::Orientation orient, int first, int last) {
                  if (orient != orientation())
                      return;
                  if (orient == Qt::Horizontal) {
                      emit dataChanged(createIndex(0, first), createIndex(0, last));
                  } else {
                      emit dataChanged(createIndex(first, 0), createIndex(last, 0));
                  }
              });
      ...
      void QHeaderDataProxyModel::disconnectFromModel()
      {
          if (m_model.isNull())
              return;
          m_model->disconnect(this);
      }
      

       How to fix: 

      Implement the connection to headerDataChanged as it is with all another slots in the method void QHeaderDataProxyModel::connectToModel()

      Attachments

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

        Activity

          People

            santhoshkumar Santhosh Kumar Selvaraj
            vmudryk Volodymyr Mudryk
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes