diff --git a/src/gui/filedetails/shareemodel.cpp b/src/gui/filedetails/shareemodel.cpp index 6f4fd97a6..85ae47c65 100644 --- a/src/gui/filedetails/shareemodel.cpp +++ b/src/gui/filedetails/shareemodel.cpp @@ -54,9 +54,7 @@ QHash ShareeModel::roleNames() const QVariant ShareeModel::data(const QModelIndex &index, const int role) const { - if (index.row() < 0 || index.row() > _sharees.size()) { - return {}; - } + Q_ASSERT(checkIndex(index, QAbstractItemModel::CheckIndexOption::IndexIsValid | QAbstractItemModel::CheckIndexOption::ParentIsInvalid)); const auto sharee = _sharees.at(index.row()); diff --git a/src/gui/filedetails/sharemodel.cpp b/src/gui/filedetails/sharemodel.cpp index 9814e3c23..c1e38e45b 100644 --- a/src/gui/filedetails/sharemodel.cpp +++ b/src/gui/filedetails/sharemodel.cpp @@ -85,9 +85,7 @@ QHash ShareModel::roleNames() const QVariant ShareModel::data(const QModelIndex &index, const int role) const { - if (!index.isValid()) { - return {}; - } + Q_ASSERT(checkIndex(index, QAbstractItemModel::CheckIndexOption::IndexIsValid | QAbstractItemModel::CheckIndexOption::ParentIsInvalid)); const auto share = _shares.at(index.row()); @@ -419,7 +417,7 @@ void ShareModel::slotRemoveShareWithId(const QString &shareId) _shareIdRecentlySetPasswords.remove(shareId); const auto shareIndex = _shareIdIndexHash.take(shareId); - if (!shareIndex.isValid()) { + if (!checkIndex(shareIndex, QAbstractItemModel::CheckIndexOption::IndexIsValid | QAbstractItemModel::CheckIndexOption::ParentIsInvalid)) { qCWarning(lcShareModel) << "Won't remove share with id:" << shareId << ", invalid share index: " << shareIndex; return;