From 3c62a048da24ae58d5d9d490914ba9e8dbdc89f0 Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Mon, 28 Dec 2020 03:37:20 -0500 Subject: fixed crash for ignore data/mark converted on multiple mods also fixes only half the selected items being handled at a time the selection must be copied first because it's live and will get invalidated when filters are being used there was some weird connect() calls for every item, not sure why --- src/mainwindow.cpp | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index ce1dc3d1..6c3801da 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -3118,41 +3118,51 @@ void MainWindow::displayModInformation(int row, ModInfoTabIDs tabID) void MainWindow::ignoreMissingData_clicked() { - QItemSelectionModel *selection = ui->modList->selectionModel(); - if (selection->hasSelection() && selection->selectedRows().count() > 1) { - for (QModelIndex idx : selection->selectedRows()) { + const auto rows = ui->modList->selectionModel()->selectedRows(); + + if (rows.count() > 1) { + std::vector changed; + + for (QModelIndex idx : rows) { int row_idx = idx.data(Qt::UserRole + 1).toInt(); ModInfo::Ptr info = ModInfo::getByIndex(row_idx); info->markValidated(true); - connect(this, SIGNAL(modListDataChanged(QModelIndex, QModelIndex)), m_OrganizerCore.modList(), SIGNAL(dataChanged(QModelIndex, QModelIndex))); + changed.push_back(info); + } - emit modListDataChanged(m_OrganizerCore.modList()->index(row_idx, 0), m_OrganizerCore.modList()->index(row_idx, m_OrganizerCore.modList()->columnCount() - 1)); + for (auto&& m : changed) { + int row_idx = ModInfo::getIndex(m->internalName()); + m_OrganizerCore.modList()->notifyChange(row_idx); } } else { ModInfo::Ptr info = ModInfo::getByIndex(m_ContextRow); info->markValidated(true); - connect(this, SIGNAL(modListDataChanged(QModelIndex, QModelIndex)), m_OrganizerCore.modList(), SIGNAL(dataChanged(QModelIndex, QModelIndex))); - - emit modListDataChanged(m_OrganizerCore.modList()->index(m_ContextRow, 0), m_OrganizerCore.modList()->index(m_ContextRow, m_OrganizerCore.modList()->columnCount() - 1)); + m_OrganizerCore.modList()->notifyChange(m_ContextRow); } } void MainWindow::markConverted_clicked() { - QItemSelectionModel *selection = ui->modList->selectionModel(); - if (selection->hasSelection() && selection->selectedRows().count() > 1) { - for (QModelIndex idx : selection->selectedRows()) { + const auto rows = ui->modList->selectionModel()->selectedRows(); + + if (rows.count() > 1) { + std::vector changed; + + for (QModelIndex idx : rows) { int row_idx = idx.data(Qt::UserRole + 1).toInt(); ModInfo::Ptr info = ModInfo::getByIndex(row_idx); info->markConverted(true); - connect(this, SIGNAL(modListDataChanged(QModelIndex, QModelIndex)), m_OrganizerCore.modList(), SIGNAL(dataChanged(QModelIndex, QModelIndex))); - emit modListDataChanged(m_OrganizerCore.modList()->index(row_idx, 0), m_OrganizerCore.modList()->index(row_idx, m_OrganizerCore.modList()->columnCount() - 1)); + changed.push_back(info); + } + + for (auto&& m : changed) { + int row_idx = ModInfo::getIndex(m->internalName()); + m_OrganizerCore.modList()->notifyChange(row_idx); } } else { ModInfo::Ptr info = ModInfo::getByIndex(m_ContextRow); info->markConverted(true); - connect(this, SIGNAL(modListDataChanged(QModelIndex, QModelIndex)), m_OrganizerCore.modList(), SIGNAL(dataChanged(QModelIndex, QModelIndex))); - emit modListDataChanged(m_OrganizerCore.modList()->index(m_ContextRow, 0), m_OrganizerCore.modList()->index(m_ContextRow, m_OrganizerCore.modList()->columnCount() - 1)); + m_OrganizerCore.modList()->notifyChange(m_ContextRow); } } -- cgit v1.3.1