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/modlist.cpp | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'src/modlist.cpp') diff --git a/src/modlist.cpp b/src/modlist.cpp index a7990132..df006e30 100644 --- a/src/modlist.cpp +++ b/src/modlist.cpp @@ -453,6 +453,8 @@ bool ModList::setData(const QModelIndex &index, const QVariant &value, int role) bool result = false; + emit aboutToChangeData(); + if (role == Qt::CheckStateRole) { bool enabled = value.toInt() == Qt::Checked; if (m_Profile->modEnabled(modID) != enabled) { @@ -512,6 +514,8 @@ bool ModList::setData(const QModelIndex &index, const QVariant &value, int role) } } + emit postDataChanged(); + IModList::ModStates newState = state(modID); if (oldState != newState) { try { @@ -1091,16 +1095,7 @@ bool ModList::deleteSelection(QAbstractItemView *itemView) bool ModList::toggleSelection(QAbstractItemView *itemView) { - QAbstractItemModel *model = itemView->model(); - - // having a filter active when dataChanged is called caused a crash - // (at least with some Qt versions) - ModListSortProxy *filterModel = qobject_cast(model); - std::vector filter; - if (filterModel != nullptr) { - filter = filterModel->categoryFilter(); - filterModel->setCategoryFilter(std::vector()); - } + emit aboutToChangeData(); QItemSelectionModel *selectionModel = itemView->selectionModel(); @@ -1115,9 +1110,7 @@ bool ModList::toggleSelection(QAbstractItemView *itemView) emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1)); - if (filterModel != nullptr) { - filterModel->setCategoryFilter(filter); - } + emit postDataChanged(); return true; } -- cgit v1.3.1