Cleanup: use ScopeGuard.
authorCarl Hetherington <cth@carlh.net>
Mon, 5 Dec 2022 19:50:16 +0000 (20:50 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 5 Dec 2022 19:50:16 +0000 (20:50 +0100)
src/wx/content_panel.cc

index b2b9f04c6bff4d36fa735102917a1240b50e4ec4..3dde85b43cd0420b2dd96c35d86311e6586754de 100644 (file)
@@ -674,14 +674,13 @@ void
 ContentPanel::add_dcp_clicked ()
 {
        auto d = new wxDirDialog (_splitter, _("Choose a DCP 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_dcp(path);
 }