summaryrefslogtreecommitdiff
path: root/src/wx/editable_list.h
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2023-01-13 13:57:28 +0100
committerCarl Hetherington <cth@carlh.net>2023-01-14 00:42:39 +0100
commitb7e65adf286ce20918797a06a910ededf8f07b7b (patch)
tree5ae7d4b521cedc75feef7b1a03b86b2e058795ad /src/wx/editable_list.h
parente002d31ac51e80bb1d008c198b864dfcb2b30cb3 (diff)
Use more ScopeGuards.
Diffstat (limited to 'src/wx/editable_list.h')
-rw-r--r--src/wx/editable_list.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/wx/editable_list.h b/src/wx/editable_list.h
index 902d1ccbb..f3a0dd957 100644
--- a/src/wx/editable_list.h
+++ b/src/wx/editable_list.h
@@ -25,6 +25,7 @@
#include "dcpomatic_button.h"
#include "wx_util.h"
+#include "lib/scope_guard.h"
#include <dcp/warnings.h>
LIBDCP_DISABLE_WARNINGS
#include <wx/listctrl.h>
@@ -233,6 +234,7 @@ private:
void add_clicked ()
{
S* dialog = new S (this);
+ ScopeGuard sg = [dialog]() { dialog->Destroy(); };
if (dialog->ShowModal() == wxID_OK) {
auto const v = dialog->get ();
@@ -244,8 +246,6 @@ private:
_set (all);
}
}
-
- dialog->Destroy ();
}
void edit_clicked ()
@@ -259,6 +259,7 @@ private:
DCPOMATIC_ASSERT (item >= 0 && item < int (all.size ()));
S* dialog = new S (this);
+ ScopeGuard sg = [dialog]() { dialog->Destroy(); };
dialog->set (all[item]);
if (dialog->ShowModal() == wxID_OK) {
auto const v = dialog->get ();
@@ -269,7 +270,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)));