mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 21:27:01 -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
|
// refresh
|
||||||
// Note: Freeze/Thaw makes flicker worse
|
// Note: Freeze/Thaw makes flicker worse
|
||||||
long item_count = (long)sorted_list.size();
|
long item_count = (long)sorted_list.size();
|
||||||
|
if (item_count == 0) {
|
||||||
|
Refresh();
|
||||||
|
} else {
|
||||||
SetItemCount(item_count);
|
SetItemCount(item_count);
|
||||||
// (re)select current item
|
// (re)select current item
|
||||||
findSelectedItemPos();
|
findSelectedItemPos();
|
||||||
focusNone();
|
focusNone();
|
||||||
focusSelectedItem(true);
|
focusSelectedItem(true);
|
||||||
// refresh items
|
// refresh items
|
||||||
if (item_count == 0) {
|
|
||||||
Refresh();
|
|
||||||
} else {
|
|
||||||
RefreshItems(0, item_count - 1);
|
RefreshItems(0, item_count - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ void KeywordList::onChangeSet() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void KeywordList::setFilter(const KeywordListFilterP& filter) {
|
void KeywordList::setFilter(const KeywordListFilterP& filter) {
|
||||||
|
|
||||||
this->filter = filter;
|
this->filter = filter;
|
||||||
refreshList();
|
refreshList();
|
||||||
}
|
}
|
||||||
@@ -191,6 +192,8 @@ int KeywordList::usage(const Keyword& kw) const {
|
|||||||
// ----------------------------------------------------------------------------- : KeywordList : Item text
|
// ----------------------------------------------------------------------------- : KeywordList : Item text
|
||||||
|
|
||||||
String KeywordList::OnGetItemText (long pos, long col) const {
|
String KeywordList::OnGetItemText (long pos, long col) const {
|
||||||
|
if (sorted_list.size() == 0) return wxEmptyString;
|
||||||
|
|
||||||
const Keyword& kw = *getKeyword(pos);
|
const Keyword& kw = *getKeyword(pos);
|
||||||
switch(col) {
|
switch(col) {
|
||||||
case 0: return kw.keyword;
|
case 0: return kw.keyword;
|
||||||
@@ -223,6 +226,7 @@ int KeywordList::OnGetItemImage(long pos) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
wxListItemAttr* KeywordList::OnGetItemAttr(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)
|
// black for set keywords, grey for game keywords (uneditable)
|
||||||
const Keyword& kw = *getKeyword(pos);
|
const Keyword& kw = *getKeyword(pos);
|
||||||
if (!kw.fixed && kw.valid) return nullptr;
|
if (!kw.fixed && kw.valid) return nullptr;
|
||||||
|
|||||||
Reference in New Issue
Block a user