mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Merge pull request #57 from llemoi/keyword_filter_crash_fix
Fixed crash when 0 keywords match filter string in keyword panel
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user