summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-08-31 00:33:12 +0200
committerCarl Hetherington <cth@carlh.net>2022-08-31 00:33:12 +0200
commit09287979ce90e809880cd17fb20deb23669f68e4 (patch)
treede5fa209555e64c3b9585f9b70a788821b9af7ac /src
parentda79e55c888b850ccc81c822386b9f4de6d91763 (diff)
Fix incorrect ordering when adding cinemas.
Diffstat (limited to 'src')
-rw-r--r--src/wx/screens_panel.cc18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/wx/screens_panel.cc b/src/wx/screens_panel.cc
index 10adad7e5..562ea8f38 100644
--- a/src/wx/screens_panel.cc
+++ b/src/wx/screens_panel.cc
@@ -251,18 +251,20 @@ ScreensPanel::add_cinema_clicked ()
return;
}
- optional<wxTreeListItem> item;
+ wxTreeListItem previous = wxTLI_FIRST;
+ bool found = false;
for (auto existing_cinema: cinemas) {
- if (!item && compare(dialog->name(), existing_cinema->name) < 0) {
- if (auto existing_item = cinema_to_item(existing_cinema)) {
- item = add_cinema (cinema, *existing_item);
- }
+ if (compare(dialog->name(), existing_cinema->name) < 0) {
+ /* existing_cinema should be after the one we're inserting */
+ found = true;
+ break;
}
+ auto item = cinema_to_item(existing_cinema);
+ DCPOMATIC_ASSERT(item);
+ previous = *item;
}
- if (!item) {
- item = add_cinema (cinema, wxTLI_LAST);
- }
+ auto item = add_cinema(cinema, found ? previous : wxTLI_LAST);
if (item) {
_targets->UnselectAll ();