From b241d096947a482ee9501cb87228df582a1a01ef Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 10 Apr 2020 14:31:34 -0700 Subject: [PATCH] mobile/models: correctly reset the connection model Qt hates empty ranges, and even for a non-empty range, this is better implemented as a reset than a remove. This fixes a crash that I have been able to create on iOS by rescanning for devices on the download page. Signed-off-by: Dirk Hohndel --- core/connectionlistmodel.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/connectionlistmodel.cpp b/core/connectionlistmodel.cpp index e4ac8bfeb..d97d4722c 100644 --- a/core/connectionlistmodel.cpp +++ b/core/connectionlistmodel.cpp @@ -39,9 +39,12 @@ void ConnectionListModel::addAddress(const QString &address) void ConnectionListModel::removeAllAddresses() { - beginRemoveRows(QModelIndex(), 0, rowCount()); + if (rowCount() == 0) + return; + + beginResetModel(); m_addresses.clear(); - endRemoveRows(); + endResetModel(); } int ConnectionListModel::indexOf(const QString &address) const