Fix extra widgets appearing when switching between subs and closed captions in the...
[dcpomatic.git] / src / wx / language_tag_widget.cc
index 37b7f6209fe5a222c4a2cfdf3bb8c3923b559bcc..88923da15c87b7a29340dd02c0483766ec5ef4e4 100644 (file)
@@ -22,7 +22,9 @@
 #include "dcpomatic_button.h"
 #include "language_tag_dialog.h"
 #include "language_tag_widget.h"
+#include "wx_ptr.h"
 #include "wx_util.h"
+#include "lib/scope_guard.h"
 #include <dcp/warnings.h>
 LIBDCP_DISABLE_WARNINGS
 #include <wx/wx.h>
@@ -55,22 +57,21 @@ LanguageTagWidget::LanguageTagWidget (wxWindow* parent, wxString tooltip, option
 }
 
 
-LanguageTagWidget::~LanguageTagWidget ()
+LanguageTagWidget::~LanguageTagWidget()
 {
-       _language->Destroy ();
-       _edit->Destroy ();
+       _language->Destroy();
+       _edit->Destroy();
 }
 
 
 void
 LanguageTagWidget::edit ()
 {
-       auto d = new LanguageTagDialog(_parent, _tag.get_value_or(dcp::LanguageTag("en")));
+       auto d = make_wx<LanguageTagDialog>(_parent, _tag.get_value_or(dcp::LanguageTag("en")));
        if (d->ShowModal() == wxID_OK) {
                set(d->get());
                Changed(d->get());
        }
-       d->Destroy ();
 }