From d25a81071c078585f14176283b89e1a6b0ad5795 Mon Sep 17 00:00:00 2001 From: Tannin Date: Wed, 10 Jun 2015 21:22:54 +0200 Subject: more generic solution to the problem fixed in changeset bb74f8eb639c, now also applied in another location --- src/modlistsortproxy.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/modlistsortproxy.cpp') diff --git a/src/modlistsortproxy.cpp b/src/modlistsortproxy.cpp index b40b4144..f646a079 100644 --- a/src/modlistsortproxy.cpp +++ b/src/modlistsortproxy.cpp @@ -376,3 +376,26 @@ bool ModListSortProxy::dropMimeData(const QMimeData *data, Qt::DropAction action return this->sourceModel()->dropMimeData(data, action, sourceIndex.row(), sourceIndex.column(), sourceIndex.parent()); } + +void ModListSortProxy::setSourceModel(QAbstractItemModel *sourceModel) +{ + QSortFilterProxyModel::setSourceModel(sourceModel); + + connect(sourceModel, SIGNAL(aboutToChangeData()), this, SLOT(aboutToChangeData())); + connect(sourceModel, SIGNAL(postDataChanged()), this, SLOT(postDataChanged())); +} + +void ModListSortProxy::aboutToChangeData() +{ + // having a filter active when dataChanged is called caused a crash + // (at least with some Qt versions) + m_PreChangeFilters = categoryFilter(); + setCategoryFilter(std::vector()); +} + +void ModListSortProxy::postDataChanged() +{ + setCategoryFilter(m_PreChangeFilters); + m_PreChangeFilters.clear(); +} + -- cgit v1.3.1