From 9c096947fee8eb296c4341fec6426d5b74fd3d36 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 5 Dec 2022 20:44:42 +0100 Subject: [PATCH] Cleanup: use ScopeGuard. --- src/wx/content_panel.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc index bf02e3930..1a5dbdc51 100644 --- a/src/wx/content_panel.cc +++ b/src/wx/content_panel.cc @@ -43,6 +43,7 @@ #include "lib/image_content.h" #include "lib/log.h" #include "lib/playlist.h" +#include "lib/scope_guard.h" #include "lib/string_text_file.h" #include "lib/string_text_file_content.h" #include "lib/text_content.h" @@ -619,14 +620,13 @@ void ContentPanel::add_folder_clicked () { auto d = new wxDirDialog (_splitter, _("Choose a folder"), wxT(""), wxDD_DIR_MUST_EXIST); + ScopeGuard sg = [d]() { d->Destroy(); }; int r = d->ShowModal (); - boost::filesystem::path const path (wx_to_std (d->GetPath ())); - d->Destroy (); - if (r != wxID_OK) { return; } + boost::filesystem::path const path(wx_to_std(d->GetPath())); add_folder(path); } -- 2.30.2