summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-04-02 23:04:27 +0200
committerCarl Hetherington <cth@carlh.net>2021-04-04 20:48:34 +0200
commitbb9a4a46266f705142a8aca41a092445a02debf0 (patch)
tree4eb801c3dbbb5c2745a2ac51339cb0c9ae7614e4 /src
parentf188fc8d92eaba89aaa63cfd7f5a2fc9836e94b6 (diff)
Stop some EnsureVisible() calls happening with out-of-range parameters.
Diffstat (limited to 'src')
-rw-r--r--src/wx/full_language_tag_dialog.cc2
-rw-r--r--src/wx/language_tag_dialog.cc8
2 files changed, 7 insertions, 3 deletions
diff --git a/src/wx/full_language_tag_dialog.cc b/src/wx/full_language_tag_dialog.cc
index 2b3aeb7de..a26dcc0bb 100644
--- a/src/wx/full_language_tag_dialog.cc
+++ b/src/wx/full_language_tag_dialog.cc
@@ -173,7 +173,7 @@ private:
{
auto search = _search->GetValue();
_list->set_search (search.ToStdString());
- if (search.Length() > 0) {
+ if (search.Length() > 0 && _list->GetItemCount() > 0) {
_list->EnsureVisible (0);
}
SearchChanged (_search->GetValue().ToStdString());
diff --git a/src/wx/language_tag_dialog.cc b/src/wx/language_tag_dialog.cc
index c72c64b31..ca08996c6 100644
--- a/src/wx/language_tag_dialog.cc
+++ b/src/wx/language_tag_dialog.cc
@@ -116,7 +116,9 @@ LanguageTagDialog::set (dcp::LanguageTag tag)
_custom.push_back (tag);
selection = _presets.size() + _custom.size() - 1;
populate_list ();
- _list->EnsureVisible (_list->GetItemCount() - 1);
+ if (_list->GetItemCount() > 0) {
+ _list->EnsureVisible (_list->GetItemCount() - 1);
+ }
} else {
selection = _presets.size() + std::distance(_custom.begin(), iter);
}
@@ -125,7 +127,9 @@ LanguageTagDialog::set (dcp::LanguageTag tag)
}
_list->SetItemState (selection, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
- _list->EnsureVisible (selection);
+ if (static_cast<int>(selection) < _list->GetItemCount()) {
+ _list->EnsureVisible (selection);
+ }
}