Skip to content

Commit 97fb50c

Browse files
committed
Add better support for default ListColumn values
This is only necessary for multiple-selection columns, and there aren't any with non-pointer entry types currently, but casting nullptr to non-pointer types isn't a great idea.
1 parent 7eb442e commit 97fb50c

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

plugins/listcolumn.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ class ListColumn
3535
bool allow_search;
3636
bool feed_mouse_set_highlight;
3737
bool feed_changed_highlight;
38+
T default_value;
3839

39-
ListColumn()
40+
ListColumn(const T default_value_ = T())
4041
{
4142
bottom_margin = 3;
4243
clear();
@@ -50,6 +51,7 @@ class ListColumn
5051
allow_search = true;
5152
feed_mouse_set_highlight = false;
5253
feed_changed_highlight = false;
54+
default_value = default_value_;
5355
}
5456

5557
void clear()
@@ -310,7 +312,7 @@ class ListColumn
310312
{
311313
vector<T> results = getSelectedElems(true);
312314
if (results.size() == 0)
313-
return (T)nullptr;
315+
return default_value;
314316
else
315317
return results[0];
316318
}

0 commit comments

Comments
 (0)