diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-12-17 22:36:45 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-12-17 22:36:45 +0100 |
| commit | 33635e7cf984eeef5eb1fbed8259e7078c5f548d (patch) | |
| tree | 05975eb2bd62ae9f1c8507abc29e452a35b7e730 | |
| parent | 11cc2c64b148201fbf962c68c21af9f5f706c257 (diff) | |
Cleanup: use ScopeGuard.
| -rw-r--r-- | src/tools/dcpomatic_player.cc | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/tools/dcpomatic_player.cc b/src/tools/dcpomatic_player.cc index 7a2ae67f4..763d219a1 100644 --- a/src/tools/dcpomatic_player.cc +++ b/src/tools/dcpomatic_player.cc @@ -56,6 +56,7 @@ #include "lib/player.h" #include "lib/player_video.h" #include "lib/ratio.h" +#include "lib/scope_guard.h" #include "lib/scoped_temporary.h" #include "lib/server.h" #include "lib/text_content.h" @@ -617,6 +618,7 @@ private: } auto c = new wxDirDialog (this, _("Select DCP to open"), d, wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST); + ScopeGuard sg = [c]() { c->Destroy(); }; int r; while (true) { @@ -633,8 +635,6 @@ private: load_dcp (dcp); Config::instance()->set_last_player_load_directory (dcp.parent_path()); } - - c->Destroy (); } void file_add_ov () @@ -645,6 +645,7 @@ private: wxStandardPaths::Get().GetDocumentsDir(), wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST ); + ScopeGuard sg = [c]() { c->Destroy(); }; int r; while (true) { @@ -677,13 +678,13 @@ private: } } - c->Destroy (); _info->triggered_update (); } void file_add_kdm () { auto d = new wxFileDialog (this, _("Select KDM")); + ScopeGuard sg = [d]() { d->Destroy(); }; if (d->ShowModal() == wxID_OK) { DCPOMATIC_ASSERT (_film); @@ -698,12 +699,10 @@ private: } } catch (exception& e) { error_dialog (this, wxString::Format (_("Could not load KDM.")), std_to_wx(e.what())); - d->Destroy (); return; } } - d->Destroy (); _info->triggered_update (); } |
