Fix crash when nonexistent string entered when filtering keywords

This commit is contained in:
Luke Le Moignan
2022-12-29 02:02:03 +00:00
parent 4c9e6fc735
commit 1b88d905b1
2 changed files with 8 additions and 3 deletions
+4 -3
View File
@@ -180,15 +180,16 @@ void ItemList::refreshList(bool refresh_current_only) {
// refresh
// Note: Freeze/Thaw makes flicker worse
long item_count = (long)sorted_list.size();
if (item_count == 0) {
Refresh();
} else {
SetItemCount(item_count);
// (re)select current item
findSelectedItemPos();
focusNone();
focusSelectedItem(true);
// refresh items
if (item_count == 0) {
Refresh();
} else {
RefreshItems(0, item_count - 1);
}
}
+4
View File
@@ -54,6 +54,7 @@ void KeywordList::onChangeSet() {
}
void KeywordList::setFilter(const KeywordListFilterP& filter) {
this->filter = filter;
refreshList();
}
@@ -191,6 +192,8 @@ int KeywordList::usage(const Keyword& kw) const {
// ----------------------------------------------------------------------------- : KeywordList : Item text
String KeywordList::OnGetItemText (long pos, long col) const {
if (sorted_list.size() == 0) return wxEmptyString;
const Keyword& kw = *getKeyword(pos);
switch(col) {
case 0: return kw.keyword;
@@ -223,6 +226,7 @@ int KeywordList::OnGetItemImage(long pos) const {
}
wxListItemAttr* KeywordList::OnGetItemAttr(long pos) const {
if (sorted_list.size() == 0) return nullptr;
// black for set keywords, grey for game keywords (uneditable)
const Keyword& kw = *getKeyword(pos);
if (!kw.fixed && kw.valid) return nullptr;