From be0790cdeeb926dcb26ef858a782005154934ae1 Mon Sep 17 00:00:00 2001 From: frang75 Date: Sat, 30 Dec 2023 10:10:42 +0100 Subject: [PATCH] Fix crash in TableView with no columns --- prj/build.txt | 2 +- src/gui/tableview.c | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/prj/build.txt b/prj/build.txt index 436d325..c1e9ea0 100644 --- a/prj/build.txt +++ b/prj/build.txt @@ -1 +1 @@ -4770 +4772 diff --git a/src/gui/tableview.c b/src/gui/tableview.c index 173517f..df9cf4f 100644 --- a/src/gui/tableview.c +++ b/src/gui/tableview.c @@ -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; } @@ -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; @@ -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;