summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2020-04-10 14:31:34 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-04-10 17:18:17 -0700
commitb241d096947a482ee9501cb87228df582a1a01ef (patch)
tree63ed730314d06d9e0b409bba2b80b7d0eda7bdaa
parent1fd8ea9d499ccb7adacc5f728ad69ba5cb5c60f8 (diff)
downloadsubsurface-b241d096947a482ee9501cb87228df582a1a01ef.tar.gz
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 <dirk@hohndel.org>
-rw-r--r--core/connectionlistmodel.cpp7
1 files 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