diff --git a/src/core/simpletreemodel.h b/src/core/simpletreemodel.h index 773962b6..8e1b4161 100644 --- a/src/core/simpletreemodel.h +++ b/src/core/simpletreemodel.h @@ -99,12 +99,14 @@ QModelIndex SimpleTreeModel::parent(const QModelIndex &idx) const { template int SimpleTreeModel::rowCount(const QModelIndex &parent) const { T *item = IndexToItem(parent); + if (!item) return 0; return item->children.count(); } template bool SimpleTreeModel::hasChildren(const QModelIndex &parent) const { T *item = IndexToItem(parent); + if (!item) return false; if (item->lazy_loaded) return !item->children.isEmpty(); else @@ -114,13 +116,13 @@ bool SimpleTreeModel::hasChildren(const QModelIndex &parent) const { template bool SimpleTreeModel::canFetchMore(const QModelIndex &parent) const { T *item = IndexToItem(parent); - return !item->lazy_loaded; + return item && !item->lazy_loaded; } template void SimpleTreeModel::fetchMore(const QModelIndex &parent) { T *item = IndexToItem(parent); - if (!item->lazy_loaded) { + if (item && !item->lazy_loaded) { LazyPopulate(item); } }