QSortFilterProxyModel crash in while Invalidating filter.
-
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 -
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
-
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@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 yourparent()
implementation?If you are not using it already, the Qt Model Test is very useful in squashing common bugs in model implementations
-
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; }
-
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