only valid index are sent to QAbstractItemModel::data
we may want to do more checks in debug mode, let's do it
if we are going to show data, let's use a const variable to contain the
current activity item
Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
QVariant ActivityListModel::data(const QModelIndex &index, int role) const
{
- Activity a;
+ Q_ASSERT(checkIndex(index, QAbstractItemModel::CheckIndexOption::IndexIsValid | QAbstractItemModel::CheckIndexOption::ParentIsInvalid));
- if (!index.isValid())
- return QVariant();
-
- a = _finalList.at(index.row());
+ const auto a = _finalList.at(index.row());
AccountStatePtr ast = AccountManager::instance()->account(a._accName);
if (!ast && _accountState != ast.data())
return QVariant();