diff options
| author | Carl Hetherington <cth@carlh.net> | 2023-01-13 13:57:28 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2023-01-14 00:42:39 +0100 |
| commit | b7e65adf286ce20918797a06a910ededf8f07b7b (patch) | |
| tree | 5ae7d4b521cedc75feef7b1a03b86b2e058795ad /src/tools/dcpomatic_kdm.cc | |
| parent | e002d31ac51e80bb1d008c198b864dfcb2b30cb3 (diff) | |
Use more ScopeGuards.
Diffstat (limited to 'src/tools/dcpomatic_kdm.cc')
| -rw-r--r-- | src/tools/dcpomatic_kdm.cc | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/tools/dcpomatic_kdm.cc b/src/tools/dcpomatic_kdm.cc index 04b37b2c6..256367977 100644 --- a/src/tools/dcpomatic_kdm.cc +++ b/src/tools/dcpomatic_kdm.cc @@ -267,17 +267,17 @@ private: void help_about () { auto d = new AboutDialog (this); + ScopeGuard sg = [d]() { d->Destroy(); }; d->ShowModal (); - d->Destroy (); } void help_report_a_problem () { auto d = new ReportProblemDialog (this, shared_ptr<Film>()); + ScopeGuard sg = [d]() { d->Destroy(); }; if (d->ShowModal () == wxID_OK) { d->report (); } - d->Destroy (); } void setup_menu (wxMenuBar* m) @@ -567,16 +567,18 @@ private: void add_dkdm_folder_clicked () { auto d = new NewDKDMFolderDialog (this); - if (d->ShowModal() == wxID_OK) { - auto new_dkdm = make_shared<DKDMGroup>(wx_to_std(d->get())); - auto parent = dynamic_pointer_cast<DKDMGroup>(selected_dkdm()); - if (!parent) { - parent = Config::instance()->dkdms (); - } - add_dkdm(new_dkdm, parent); - update_dkdm_view(); + ScopeGuard sg = [d]() { d->Destroy(); }; + if (d->ShowModal() != wxID_OK) { + return; } - d->Destroy (); + + auto new_dkdm = make_shared<DKDMGroup>(wx_to_std(d->get())); + auto parent = dynamic_pointer_cast<DKDMGroup>(selected_dkdm()); + if (!parent) { + parent = Config::instance()->dkdms (); + } + add_dkdm(new_dkdm, parent); + update_dkdm_view(); } void update_dkdm_view() @@ -720,11 +722,11 @@ private: this, _("Select DKDM File"), wxEmptyString, wxEmptyString, wxT("XML files (*.xml)|*.xml"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); + ScopeGuard sg = [d]() { d->Destroy(); }; if (d->ShowModal() == wxID_OK) { dkdm->dkdm().as_xml(wx_to_std(d->GetPath())); } - d->Destroy (); } void dkdm_search_changed() |
