Add wx_ptr and use it instead of ScopeGuard in a lot of places.
[dcpomatic.git] / src / wx / editable_list.h
index 902d1ccbbf213e7c53288cd1066579de58222348..f8050cac5a3b23b5266742b7d3647e4208e3b299 100644 (file)
@@ -24,6 +24,7 @@
 
 
 #include "dcpomatic_button.h"
+#include "wx_ptr.h"
 #include "wx_util.h"
 #include <dcp/warnings.h>
 LIBDCP_DISABLE_WARNINGS
@@ -232,7 +233,7 @@ private:
 
        void add_clicked ()
        {
-               S* dialog = new S (this);
+               auto dialog = make_wx<S>(this);
 
                if (dialog->ShowModal() == wxID_OK) {
                        auto const v = dialog->get ();
@@ -244,8 +245,6 @@ private:
                                _set (all);
                        }
                }
-
-               dialog->Destroy ();
        }
 
        void edit_clicked ()
@@ -258,7 +257,7 @@ private:
                std::vector<T> all = _get ();
                DCPOMATIC_ASSERT (item >= 0 && item < int (all.size ()));
 
-               S* dialog = new S (this);
+               auto dialog = make_wx<S>(this);
                dialog->set (all[item]);
                if (dialog->ShowModal() == wxID_OK) {
                        auto const v = dialog->get ();
@@ -269,7 +268,6 @@ private:
 
                        all[item] = v.get ();
                }
-               dialog->Destroy ();
 
                for (size_t i = 0; i < _columns.size(); ++i) {
                        _list->SetItem (item, i, std_to_wx (_column (all[item], i)));