From bb8ddd298ed2925a94b95651534a563992f840ea Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 19 Jan 2023 00:03:09 +0100 Subject: [PATCH] Use ScopeGuard for _no_check_selection --- src/wx/content_panel.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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 (); } -- 2.30.2