From: Carl Hetherington Date: Wed, 18 Jan 2023 23:03:09 +0000 (+0100) Subject: Use ScopeGuard for _no_check_selection X-Git-Tag: v2.16.41~7 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=bb8ddd298ed2925a94b95651534a563992f840ea Use ScopeGuard for _no_check_selection --- diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc index fd1315747..77607ad16 100644 --- a/src/wx/content_panel.cc +++ b/src/wx/content_panel.cc @@ -817,14 +817,16 @@ ContentPanel::set_selection (weak_ptr wc) 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 (); }