From bc9b7a05f4dafec3c0812cfc1f3c6d3d5dd702f1 Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Mon, 13 Feb 2023 19:12:58 +0100 Subject: [PATCH] repay some desbt in ActivityListModel::data 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 --- src/gui/tray/activitylistmodel.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/gui/tray/activitylistmodel.cpp b/src/gui/tray/activitylistmodel.cpp index 7b152a984..e7b7b38f5 100644 --- a/src/gui/tray/activitylistmodel.cpp +++ b/src/gui/tray/activitylistmodel.cpp @@ -130,12 +130,9 @@ void ActivityListModel::setDisplayActions(bool value) 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(); -- 2.30.2