Fix crash at startup

Not sure this is the right fix, but at least it doesn't crash any more.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2014-09-17 15:48:57 -07:00
parent 0d1da0563b
commit 434e7a6a71

View file

@ -2176,18 +2176,23 @@ bool TagFilterSortModel::filterAcceptsRow(int source_row, const QModelIndex &sou
struct tag_entry *head = d->tag_list; struct tag_entry *head = d->tag_list;
if (!head) { // last tag means "Show empty tags"; if (!head) { // last tag means "Show empty tags";
return TagFilterModel::instance()->checkState[TagFilterModel::instance()->rowCount() - 1]; if (TagFilterModel::instance()->rowCount() > 0)
return TagFilterModel::instance()->checkState[TagFilterModel::instance()->rowCount() - 1];
else
return true;
} }
// have at least one tag. // have at least one tag.
QStringList tagList = TagFilterModel::instance()->stringList(); QStringList tagList = TagFilterModel::instance()->stringList();
tagList.removeLast(); // remove the "Show Empty Tags"; if (!tagList.isEmpty()) {
while (head) { tagList.removeLast(); // remove the "Show Empty Tags";
QString tagName(head->tag->name); while (head) {
int index = tagList.indexOf(tagName); QString tagName(head->tag->name);
if (TagFilterModel::instance()->checkState[index]) int index = tagList.indexOf(tagName);
return true; if (TagFilterModel::instance()->checkState[index])
head = head->next; return true;
head = head->next;
}
} }
return false; return false;
} }