Commit 92b5dda0 authored by Allen Winter's avatar Allen Winter

storagemodel.cpp - collectionForId() improve

crash guards, Last Search folder seems particularly vulnerable
ok'd by Laurent
parent 294a33c1
Pipeline #45183 passed with stage
in 27 minutes and 53 seconds
......@@ -497,14 +497,18 @@ Akonadi::Collection StorageModel::collectionForId(Akonadi::Collection::Id colId)
{
// Get ETM
auto *childrenProxy = static_cast<QAbstractProxyModel *>(d->mChildrenFilterModel);
QAbstractItemModel *etm = childrenProxy->sourceModel();
// get index in EntityTreeModel
const QModelIndex idx = EntityTreeModel::modelIndexForCollection(etm, Collection(colId));
Q_ASSERT(idx.isValid());
// get and return collection
return idx.data(EntityTreeModel::CollectionRole).value<Collection>();
if (childrenProxy) {
QAbstractItemModel *etm = childrenProxy->sourceModel();
if (etm) {
// get index in EntityTreeModel
const QModelIndex idx = EntityTreeModel::modelIndexForCollection(etm, Collection(colId));
if (idx.isValid()) {
// get and return collection
return idx.data(EntityTreeModel::CollectionRole).value<Collection>();
}
}
}
return Akonadi::Collection();
}
void StorageModel::resetModelStorage()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment