projects
/
dcpomatic.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use more ScopeGuards.
[dcpomatic.git]
/
src
/
wx
/
editable_list.h
diff --git
a/src/wx/editable_list.h
b/src/wx/editable_list.h
index bd89090485a2fcfb8250c2ea0331f4fff70772e1..f3a0dd957d01a11989640d4f6493df9caad5930f 100644
(file)
--- 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 "dcpomatic_button.h"
#include "wx_util.h"
+#include "lib/scope_guard.h"
#include <dcp/warnings.h>
LIBDCP_DISABLE_WARNINGS
#include <wx/listctrl.h>
#include <dcp/warnings.h>
LIBDCP_DISABLE_WARNINGS
#include <wx/listctrl.h>
@@
-61,6
+62,13
@@
namespace EditableListButton
};
};
+enum class EditableListTitle
+{
+ VISIBLE,
+ INVISIBLE
+};
+
+
/** @param T type of things being edited.
* @param S dialog to edit a thing.
* @param get Function to get a std::vector of the things being edited.
/** @param T type of things being edited.
* @param S dialog to edit a thing.
* @param get Function to get a std::vector of the things being edited.
@@
-77,7
+85,7
@@
public:
std::function<std::vector<T> ()> get,
std::function<void (std::vector<T>)> set,
std::function<std::string (T, int)> column,
std::function<std::vector<T> ()> get,
std::function<void (std::vector<T>)> set,
std::function<std::string (T, int)> column,
-
bool
title,
+
EditableListTitle
title,
int buttons
)
: wxPanel (parent)
int buttons
)
: wxPanel (parent)
@@
-91,7
+99,7
@@
public:
SetSizer (_sizer);
long style = wxLC_REPORT | wxLC_SINGLE_SEL;
SetSizer (_sizer);
long style = wxLC_REPORT | wxLC_SINGLE_SEL;
- if (
!title
) {
+ if (
title == EditableListTitle::INVISIBLE
) {
style |= wxLC_NO_HEADER;
}
style |= wxLC_NO_HEADER;
}
@@
-226,6
+234,7
@@
private:
void add_clicked ()
{
S* dialog = new S (this);
void add_clicked ()
{
S* dialog = new S (this);
+ ScopeGuard sg = [dialog]() { dialog->Destroy(); };
if (dialog->ShowModal() == wxID_OK) {
auto const v = dialog->get ();
if (dialog->ShowModal() == wxID_OK) {
auto const v = dialog->get ();
@@
-237,8
+246,6
@@
private:
_set (all);
}
}
_set (all);
}
}
-
- dialog->Destroy ();
}
void edit_clicked ()
}
void edit_clicked ()
@@
-252,6
+259,7
@@
private:
DCPOMATIC_ASSERT (item >= 0 && item < int (all.size ()));
S* dialog = new S (this);
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 ();
dialog->set (all[item]);
if (dialog->ShowModal() == wxID_OK) {
auto const v = dialog->get ();
@@
-262,7
+270,6
@@
private:
all[item] = v.get ();
}
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)));
for (size_t i = 0; i < _columns.size(); ++i) {
_list->SetItem (item, i, std_to_wx (_column (all[item], i)));