Skip to content

Commit

Permalink
Prevent crash from early ConversationModel::fetchMore
Browse files Browse the repository at this point in the history
When called before the model data is ready, this would crash under
eventAt.
  • Loading branch information
special committed Aug 9, 2012
1 parent cb789bf commit 17efab5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/conversationmodel.cpp
Expand Up @@ -336,6 +336,9 @@ void ConversationModel::fetchMore(const QModelIndex &parent)
Q_UNUSED(parent);
Q_D(ConversationModel);

if (!d->isModelReady() || d->eventRootItem->childCount() < 1)
return;

EventsQuery query = d->buildQuery();

Event &event = d->eventRootItem->eventAt(d->eventRootItem->childCount() - 1);
Expand Down
1 change: 1 addition & 0 deletions src/eventtreeitem.cpp
Expand Up @@ -79,6 +79,7 @@ EventTreeItem *EventTreeItem::child(int row)

Event &EventTreeItem::eventAt(int row)
{
Q_ASSERT(row >= 0 && row < children.count());
return children.value(row)->event();
}

Expand Down

0 comments on commit 17efab5

Please sign in to comment.