X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Fwx%2Fcontent_panel.cc;fp=src%2Fwx%2Fcontent_panel.cc;h=1a5dbdc51952b50e013bf40405954b0b214895e2;hp=bf02e39305146fe3d650f2fd9bd2a556add4c789;hb=9c096947fee8eb296c4341fec6426d5b74fd3d36;hpb=0fa422e8f419ba1388448fe384e4998a6b3426d4 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); }