Use ScopeGuard for _no_check_selection
authorCarl Hetherington <cth@carlh.net>
Wed, 18 Jan 2023 23:03:09 +0000 (00:03 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 18 Jan 2023 23:03:09 +0000 (00:03 +0100)
src/wx/content_panel.cc

index fd13157474a391c55e56e3a8d59ab5cf25ec56cd..77607ad16cb39ca01eb35c62f7b68e85f250c8cb 100644 (file)
@@ -817,14 +817,16 @@ ContentPanel::set_selection (weak_ptr<Content> wc)
 void
 ContentPanel::set_selection (ContentList cl)
 {
 void
 ContentPanel::set_selection (ContentList cl)
 {
-       _no_check_selection = true;
+       {
+               _no_check_selection = true;
+               ScopeGuard sg = [this]() { _no_check_selection = false; };
 
 
-       auto content = _film->content ();
-       for (size_t i = 0; i < content.size(); ++i) {
-               set_selected_state(i, find(cl.begin(), cl.end(), content[i]) != cl.end());
+               auto content = _film->content ();
+               for (size_t i = 0; i < content.size(); ++i) {
+                       set_selected_state(i, find(cl.begin(), cl.end(), content[i]) != cl.end());
+               }
        }
 
        }
 
-       _no_check_selection = false;
        check_selection ();
 }
 
        check_selection ();
 }