More stack-allocated Dialog objects.
[dcpomatic.git] / src / wx / templates_dialog.cc
index 3336277b6051da1ce1f447e36c063cf36ddaebd3..145e4f2b97119d3557c7805705d3e4ce39265d99 100644 (file)
@@ -130,17 +130,18 @@ TemplatesDialog::rename_clicked ()
        li.m_mask = wxLIST_MASK_TEXT;
        _list->GetItem (li);
 
-       auto d = new RenameTemplateDialog (this);
-       d->set (li.m_text);
-       if (d->ShowModal() == wxID_OK) {
-               if (!d->get().IsEmpty()) {
-                       Config::instance()->rename_template (wx_to_std (li.m_text), wx_to_std (d->get ()));
-                       _list->SetItem (item, 0, d->get());
-               } else {
-                       error_dialog (this, _("Template names must not be empty."));
-               }
+       RenameTemplateDialog dialog(this);
+       dialog.set(li.m_text);
+       if (dialog.ShowModal() != wxID_OK) {
+               return;
+       }
+
+       if (!dialog.get().IsEmpty()) {
+               Config::instance()->rename_template(wx_to_std(li.m_text), wx_to_std(dialog.get()));
+               _list->SetItem(item, 0, dialog.get());
+       } else {
+               error_dialog (this, _("Template names must not be empty."));
        }
-       d->Destroy ();
 }