Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSortFilterProxyModel crash in while Invalidating filter.
Forum Update on Monday, May 27th 2025

QSortFilterProxyModel crash in while Invalidating filter.

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 3 Posters 2.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    seetharam
    wrote on 6 Jul 2018, 13:51 last edited by
    #1

    Hi,
    I am using QT 5.6.0 version.
    I am facing a crash while invalidating QSortFilerProxyModel which is used in QTreeView.

    stack Trace is as below
    Qt5Core.dll!QModelIndex::parent() Line 411 C++
    Qt5Core.dll!QSortFilterProxyModelPrivate::source_to_proxy(const QModelIndex & source_index) Line 396 C++
    Qt5Core.dll!QSortFilterProxyModel::mapFromSource(const QModelIndex & sourceIndex) Line 2762 C++
    Qt5Core.dll!QSortFilterProxyModel::parent(const QModelIndex & child) Line 1894 C++
    Qt5Core.dll!QModelIndex::parent() Line 411 C++
    Qt5Core.dll!QPersistentModelIndex::parent() Line 365 C++
    Qt5Core.dll!QItemSelectionRange::isValid() Line 139 C++
    Qt5Core.dll!indexesFromRange<QVector<QPersistentModelIndex> >(const QItemSelectionRange & range, QVector<QPersistentModelIndex> & result) Line 308 C++
    Qt5Core.dll!qSelectionPersistentindexes(const QItemSelection & sel) Line 477 C++
    Qt5Core.dll!QItemSelectionModelPrivate::_q_layoutAboutToBeChanged(const QList<QPersistentModelIndex> & __formal, QAbstractItemModel::LayoutChangeHint hint) Line 889 C++
    Qt5Core.dll!QItemSelectionModel::qt_static_metacall(QObject * _o, QMetaObject::Call _c, int _id, void * * _a) Line 422 C++
    Qt5Core.dll!QMetaObject::activate(QObject * sender, int signalOffset, int local_signal_index, void * * argv) Line 3732 C++
    Qt5Core.dll!QMetaObject::activate(QObject * sender, const QMetaObject * m, int local_signal_index, void * * argv) Line 3595 C++
    Qt5Core.dll!QAbstractItemModel::layoutAboutToBeChanged(const QList<QPersistentModelIndex> & _t1, QAbstractItemModel::LayoutChangeHint _t2) Line 589 C++
    Qt5Core.dll!QSortFilterProxyModel::clear() Line 2560 C++
    Could you plesae help me to resolve this sisue ?

    Thanks in advance ,
    Seetharam

    1 Reply Last reply
    0
    • V Offline
      V Offline
      VRonin
      wrote on 6 Jul 2018, 14:26 last edited by
      #2
      • What source model are you using?
      • Are you using any form of automatic sorting when data changes?

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      0
      • S Offline
        S Offline
        seetharam
        wrote on 6 Jul 2018, 14:56 last edited by
        #3

        Hi,
        Thanks for the reply.
        I am using Source Model as QAbstractItemModel.

        I am not using any automatic sorting , but I am calling QSortFilterProxyModel->Invalidate() function to un- filter out data.

        Regards,
        Seetharam

        V 1 Reply Last reply 6 Jul 2018, 15:36
        0
        • C Online
          C Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 6 Jul 2018, 15:27 last edited by
          #4

          We need a proper testcase to say anything about this. Also there were some fixes after 5.6.0 in this area so I would fix test it with 5.11

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          3
          • S seetharam
            6 Jul 2018, 14:56

            Hi,
            Thanks for the reply.
            I am using Source Model as QAbstractItemModel.

            I am not using any automatic sorting , but I am calling QSortFilterProxyModel->Invalidate() function to un- filter out data.

            Regards,
            Seetharam

            V Offline
            V Offline
            VRonin
            wrote on 6 Jul 2018, 15:36 last edited by
            #5

            @seetharam said in QSortFilterProxyModel crash in while Invalidating filter.:

            I am using Source Model as QAbstractItemModel.

            That means custom model implementation.
            can you show us your parent() implementation?

            If you are not using it already, the Qt Model Test is very useful in squashing common bugs in model implementations

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            1 Reply Last reply
            2
            • S Offline
              S Offline
              seetharam
              wrote on 9 Jul 2018, 06:13 last edited by VRonin 7 Sept 2018, 07:33
              #6
              template <class TreeItem>
              QModelIndex
                  ModelImpl<TreeItem>::parent(
                      const QModelIndex &curindex) const
              {
                  QModelIndex res;
                  if (curindex.isValid())
                  {
                      TreeItem *childItem = GetItem(curindex);
                      if ( childItem )
                      {
                          TreeItem *parentItem = childItem->parent();  // here is the problem 
                          res = CreateIndexFromItem( parentItem );
                      }
                  }
                  return res;
              }
              
              1 Reply Last reply
              0
              • V Offline
                V Offline
                VRonin
                wrote on 9 Jul 2018, 07:34 last edited by
                #7

                What's inside TreeItem::parent()?

                "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                ~Napoleon Bonaparte

                On a crusade to banish setIndexWidget() from the holy land of Qt

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  seetharam
                  wrote on 10 Jul 2018, 15:03 last edited by
                  #8

                  TreeItem::parent is default , there is no overriden function.

                  1 Reply Last reply
                  0
                  • V Offline
                    V Offline
                    VRonin
                    wrote on 10 Jul 2018, 16:13 last edited by
                    #9

                    I have no idea what's the base class of TreeItem though... it's not a Qt class

                    "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                    ~Napoleon Bonaparte

                    On a crusade to banish setIndexWidget() from the holy land of Qt

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      seetharam
                      wrote on 11 Jul 2018, 09:53 last edited by
                      #10

                      TreeItem is nothing but QTreeWidgetItem

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        seetharam
                        wrote on 17 Jul 2018, 10:27 last edited by VRonin
                        #11

                        Hi
                        Am getting crash in below place.

                        xxxxx.dll!Vtree::ModelImpl<xxxxx::ItemBase>::rowCount(const QModelIndex & parent) Line 380	C++
                        Qt5Core.dll!QAbstractItemModel::hasIndex(int row, int column, const QModelIndex & parent) Line 1683	C++
                        xxxxx.dll!Vtree::ModelImpl<xxxxx::ItemBase>::index(int row, int column, const QModelIndex & parent) Line 296	C++
                        Qt5Core.dll!QSortFilterProxyModelPrivate::proxy_to_source(const QModelIndex & proxy_index) Line 383	C++
                        Qt5Core.dll!QSortFilterProxyModel::mapToSource(const QModelIndex & proxyIndex) Line 2750	C++
                        Qt5Core.dll!QSortFilterProxyModelPrivate::store_persistent_indexes() Line 1019	C++
                        Qt5Core.dll!QSortFilterProxyModelPrivate::_q_clearMapping() Line 310	C++
                        Qt5Core.dll!QSortFilterProxyModel::clear() Line 2562	C++
                        

                        As per my analysis , I suspect that the proxy_index itself is getting currupted in below code.

                        QModelIndexPairList QSortFilterProxyModelPrivate::store_persistent_indexes()
                        {
                            Q_Q(QSortFilterProxyModel);
                            QModelIndexPairList source_indexes;
                            foreach (QPersistentModelIndexData *data, persistent.indexes) {
                                QModelIndex proxy_index = data->index;
                                QModelIndex source_index = q->mapToSource(proxy_index);
                                source_indexes.append(qMakePair(proxy_index, QPersistentModelIndex(source_index)));
                            }
                            return source_indexes;
                        }
                        

                        Could you please Help me to solve this issue .
                        Could you please mention the fixed release of QT if this is known issue according to above stack trace.
                        Thanks and Regards,
                        Seetharam

                        1 Reply Last reply
                        0
                        • V Offline
                          V Offline
                          VRonin
                          wrote on 17 Jul 2018, 10:46 last edited by
                          #12

                          I'm quite confident the problem is inside Vtree::ModelImpl<xxxxx::ItemBase> and not inside QSortFilterProxyModel. unfortunately if you can't share your model code ther's little we can do to help you

                          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                          ~Napoleon Bonaparte

                          On a crusade to banish setIndexWidget() from the holy land of Qt

                          1 Reply Last reply
                          0

                          1/12

                          6 Jul 2018, 13:51

                          • Login

                          • Login or register to search.
                          1 out of 12
                          • First post
                            1/12
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved