Add wx_ptr and use it instead of ScopeGuard in a lot of places.
[dcpomatic.git] / src / wx / fonts_dialog.cc
index 14fb368d3a31d5e09fa33c8e1507db502f821d4a..9e38e9e687ff1e4f3b842fc4531d903da1435f99 100644 (file)
 #include "dcpomatic_button.h"
 #include "fonts_dialog.h"
 #include "system_font_dialog.h"
+#include "wx_ptr.h"
 #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
@@ -183,17 +185,13 @@ FontsDialog::set_from_file_clicked ()
         default_dir = "/System/Library/Fonts";
 #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 ();
+       auto d = make_wx<wxFileDialog>(this, _("Choose a font file"), default_dir, wxT(""), wxT("*.ttf;*.otf;*.ttc"), wxFD_CHANGE_DIR);
 
-       if (r != wxID_OK) {
-               d->Destroy ();
+       if (d->ShowModal() != wxID_OK) {
                return;
        }
 
        font->set_file (wx_to_std(d->GetPath()));
-       d->Destroy ();
-
        setup ();
 }
 
@@ -206,15 +204,13 @@ FontsDialog::set_from_system_font_clicked()
                return;
        }
 
-       auto dialog = new SystemFontDialog(this);
-       auto const r = dialog->ShowModal();
-       if (r == wxID_OK) {
+       auto dialog = make_wx<SystemFontDialog>(this);
+       if (dialog->ShowModal() == wxID_OK) {
                auto font_file = dialog->get_font();
                if (font_file) {
                        font->set_file(*font_file);
                }
        }
 
-       dialog->Destroy();
        setup ();
 }