mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-22 04:55:48 +03:00
Replace manual index bound checks with calls to checkIndex
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
parent
fb4bb95b91
commit
639fb21a13
2 changed files with 3 additions and 7 deletions
|
@ -54,9 +54,7 @@ QHash<int, QByteArray> 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());
|
||||
|
||||
|
|
|
@ -85,9 +85,7 @@ QHash<int, QByteArray> 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;
|
||||
|
|
Loading…
Reference in a new issue