Fix crash when adding cinemas while a search is in force (#2378).
[dcpomatic.git] / src / wx / screens_panel.cc
index b7defe0e9be39e482d6163fe1f4f1972edb21330..1d94d1acb9f8027a571403d1811698bdbb73f2ac 100644 (file)
@@ -249,7 +249,12 @@ ScreensPanel::add_cinema_clicked ()
 
                wxTreeListItem previous = wxTLI_FIRST;
                bool found = false;
+               auto search = wx_to_std(_search->GetValue());
+               convert_to_lower(search);
                for (auto existing_cinema: cinemas) {
+                       if (!matches_search(existing_cinema, search)) {
+                               continue;
+                       }
                        if (_collator.compare(dialog->name(), existing_cinema->name) < 0) {
                                /* existing_cinema should be after the one we're inserting */
                                found = true;