Fix extra widgets appearing when switching between subs and closed captions in the...
[dcpomatic.git] / src / wx / language_tag_widget.cc
index 3df2b6914a7963e5ccded2e21a2adb7fc93f8eed..88923da15c87b7a29340dd02c0483766ec5ef4e4 100644 (file)
 #include "dcpomatic_button.h"
 #include "language_tag_dialog.h"
 #include "language_tag_widget.h"
+#include "wx_ptr.h"
 #include "wx_util.h"
-#include "lib/warnings.h"
-DCPOMATIC_DISABLE_WARNINGS
+#include "lib/scope_guard.h"
+#include <dcp/warnings.h>
+LIBDCP_DISABLE_WARNINGS
 #include <wx/wx.h>
-DCPOMATIC_ENABLE_WARNINGS
+LIBDCP_ENABLE_WARNINGS
 
 
 using boost::optional;
@@ -55,21 +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")));
-       d->ShowModal ();
-       set (d->get());
-       Changed (d->get());
-       d->Destroy ();
+       auto d = make_wx<LanguageTagDialog>(_parent, _tag.get_value_or(dcp::LanguageTag("en")));
+       if (d->ShowModal() == wxID_OK) {
+               set(d->get());
+               Changed(d->get());
+       }
 }