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>
This commit is contained in:
Dirk Hohndel 2020-04-10 14:31:34 -07:00
parent 1fd8ea9d49
commit b241d09694

View file

@ -39,9 +39,12 @@ void ConnectionListModel::addAddress(const QString &address)
void ConnectionListModel::removeAllAddresses() void ConnectionListModel::removeAllAddresses()
{ {
beginRemoveRows(QModelIndex(), 0, rowCount()); if (rowCount() == 0)
return;
beginResetModel();
m_addresses.clear(); m_addresses.clear();
endRemoveRows(); endResetModel();
} }
int ConnectionListModel::indexOf(const QString &address) const int ConnectionListModel::indexOf(const QString &address) const