Fix crash in DiveTripModel.

A left click in the treeview header leads to a call to createIndex which
results in a null pointer dereference.

Signed-off-by: Amit Chaudhuri <amit.k.chaudhuri@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Amit Chaudhuri 2013-05-11 11:38:24 +01:00 committed by Dirk Hohndel
parent 06d296a17d
commit 5105d6a333

View file

@ -650,7 +650,7 @@ QModelIndex DiveTripModel::parent(const QModelIndex& index) const
TreeItemDT* childItem = static_cast<TreeItemDT*>(index.internalPointer());
TreeItemDT* parentItem = childItem->parent;
if (parentItem == rootItem)
if (parentItem == rootItem || !parentItem)
return QModelIndex();
return createIndex(parentItem->row(), 0, parentItem);