diff options
| author | Carl Hetherington <cth@carlh.net> | 2023-01-14 01:23:06 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2023-01-14 01:23:06 +0100 |
| commit | 5800e1f2abecb709cbdc1408d1328f29cdbcb370 (patch) | |
| tree | c31c5a9bdb559855e22973ff8ccfb8b68db37891 /src/wx/fonts_dialog.cc | |
| parent | abcd6c9182507e6336a1839661dac856d5bea553 (diff) | |
Use ScopeGuard more.
Diffstat (limited to 'src/wx/fonts_dialog.cc')
| -rw-r--r-- | src/wx/fonts_dialog.cc | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/wx/fonts_dialog.cc b/src/wx/fonts_dialog.cc index 14fb368d3..b21bb8498 100644 --- a/src/wx/fonts_dialog.cc +++ b/src/wx/fonts_dialog.cc @@ -25,6 +25,7 @@ #include "wx_util.h" #include "lib/content.h" #include "lib/font.h" +#include "lib/scope_guard.h" #include "lib/text_content.h" #include <dcp/warnings.h> LIBDCP_DISABLE_WARNINGS @@ -184,16 +185,13 @@ FontsDialog::set_from_file_clicked () #endif auto d = new wxFileDialog (this, _("Choose a font file"), default_dir, wxT(""), wxT("*.ttf;*.otf;*.ttc"), wxFD_CHANGE_DIR); - int const r = d->ShowModal (); + ScopeGuard sg = [d]() { d->Destroy(); }; - if (r != wxID_OK) { - d->Destroy (); + if (d->ShowModal() != wxID_OK) { return; } font->set_file (wx_to_std(d->GetPath())); - d->Destroy (); - setup (); } @@ -207,14 +205,13 @@ FontsDialog::set_from_system_font_clicked() } auto dialog = new SystemFontDialog(this); - auto const r = dialog->ShowModal(); - if (r == wxID_OK) { + ScopeGuard sg = [dialog]() { dialog->Destroy(); }; + if (dialog->ShowModal() == wxID_OK) { auto font_file = dialog->get_font(); if (font_file) { font->set_file(*font_file); } } - dialog->Destroy(); setup (); } |
