Skip to content

Commit

Permalink
Fix crash in TableView with no columns
Browse files Browse the repository at this point in the history
  • Loading branch information
frang75 committed Dec 30, 2023
1 parent 9873420 commit be0790c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion prj/build.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4770
4772
7 changes: 6 additions & 1 deletion src/gui/tableview.c
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,10 @@ static void i_row_height(TData *data)
data->row_height = height;
arrst_end();

/* Fix crash if no column defined */
if (data->row_height == 0)
data->row_height = 15;

if (data->hlines == TRUE)
data->row_height += 1;
}
Expand Down Expand Up @@ -1150,7 +1154,7 @@ static void i_OnDown(TableView *view, Event *e)
const EvMouse *p = event_params(e, EvMouse);
uint32_t n = data->num_rows;

if (n > 0 && p->button == ekGUI_MOUSE_LEFT)
if (p->button == ekGUI_MOUSE_LEFT)
{
data->mouse_down = TRUE;

Expand Down Expand Up @@ -1560,6 +1564,7 @@ TableView *tableview_create(void)
_view_set_subtype(view, "TableView");
view_size(view, s2df(256, 128));
i_head_height(data);
i_row_height(data);
i_document_size((TableView *)view, data);
view_data(view, &data, i_destroy_data, TData);
return (TableView *)view;
Expand Down

0 comments on commit be0790c

Please sign in to comment.