summaryrefslogtreecommitdiffstats
path: root/qt-ui/models.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-09-17 15:48:57 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-09-17 15:48:57 -0700
commit434e7a6a7173dcf6abe846e9972a01edce6a571b (patch)
tree7cdf36cb217ac142ab311dc359c41fcab5c14fdb /qt-ui/models.cpp
parent0d1da0563b949695651cce7eb49f9a25b80d3431 (diff)
downloadsubsurface-434e7a6a7173dcf6abe846e9972a01edce6a571b.tar.gz
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>
Diffstat (limited to 'qt-ui/models.cpp')
-rw-r--r--qt-ui/models.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp
index 162d6b482..a1813f5b1 100644
--- a/qt-ui/models.cpp
+++ b/qt-ui/models.cpp
@@ -2176,18 +2176,23 @@ bool TagFilterSortModel::filterAcceptsRow(int source_row, const QModelIndex &sou
struct tag_entry *head = d->tag_list;
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.
QStringList tagList = TagFilterModel::instance()->stringList();
- tagList.removeLast(); // remove the "Show Empty Tags";
- while (head) {
- QString tagName(head->tag->name);
- int index = tagList.indexOf(tagName);
- if (TagFilterModel::instance()->checkState[index])
- return true;
- head = head->next;
+ if (!tagList.isEmpty()) {
+ tagList.removeLast(); // remove the "Show Empty Tags";
+ while (head) {
+ QString tagName(head->tag->name);
+ int index = tagList.indexOf(tagName);
+ if (TagFilterModel::instance()->checkState[index])
+ return true;
+ head = head->next;
+ }
}
return false;
}