From fac16b4b0c3a9b7209c7bf3ec74a770d19ca93a4 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Tue, 4 Oct 2022 18:32:22 +0200 Subject: [PATCH] fix: prevent crash when filtering Signed-off-by: Sefa Eyeoglu --- launcher/ui/instanceview/InstanceView.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/launcher/ui/instanceview/InstanceView.cpp b/launcher/ui/instanceview/InstanceView.cpp index e8503edcd..543f0184e 100644 --- a/launcher/ui/instanceview/InstanceView.cpp +++ b/launcher/ui/instanceview/InstanceView.cpp @@ -32,6 +32,7 @@ #include #include +#include InstanceView::InstanceView(QWidget* parent, InstanceList* instances) : QStackedWidget(parent), m_instances(instances) { @@ -170,6 +171,14 @@ void InstanceView::activateInstance(const QModelIndex& index) void InstanceView::currentRowChanged(const QModelIndex& current, const QModelIndex& previous) { + // don't fire event, if row changed in inactive model + QSortFilterProxyModel* m = m_tableProxy; + if (m_displayMode == GridMode) + m = m_gridProxy; + + if (current.model() != m) + return; + InstancePtr inst1, inst2; if (current.isValid()) { int row = mappedIndex(current).row(); @@ -215,10 +224,11 @@ void InstanceView::contextMenuRequested(const QPoint pos) QModelIndex InstanceView::mappedIndex(const QModelIndex& index) const { - if (m_displayMode == DisplayMode::GridMode) { + if (index.model() == m_tableProxy) + return m_tableProxy->mapToSource(index); + if (index.model() == m_gridProxy) return m_gridProxy->mapToSource(index); - } - return m_tableProxy->mapToSource(index); + return index; } void InstanceView::setFilterQuery(const QString& query)