Supporters update.
[dcpomatic.git] / src / wx / language_tag_dialog.cc
index 96e7c528390b170a09a760cdad322249e4dbe554..df2b74976649d2d90aa951f8e8ea5d359e6290df 100644 (file)
 #include "language_tag_dialog.h"
 #include "wx_util.h"
 #include "lib/config.h"
+#include <dcp/language_tag.h>
+#include <dcp/warnings.h>
+LIBDCP_DISABLE_WARNINGS
 #include <wx/listctrl.h>
 #include <wx/wx.h>
-#include <dcp/language_tag.h>
+LIBDCP_ENABLE_WARNINGS
 
 
 using std::vector;
@@ -116,7 +119,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,6 +130,9 @@ LanguageTagDialog::set (dcp::LanguageTag tag)
        }
 
        _list->SetItemState (selection, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
+       if (static_cast<int>(selection) < _list->GetItemCount()) {
+               _list->EnsureVisible (selection);
+       }
 }