From 2f0c4b90d78d9cc6d4e475723c405d021bae8ee0 Mon Sep 17 00:00:00 2001 From: Celine Mercier Date: Fri, 14 Apr 2017 16:25:55 +0200 Subject: [PATCH] Fixed a problem where a view would have a wrong line count after adding a first column to it if there was already a Line selection associated (happening when cloning), and fixed a bad error check. --- src/obiview.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/obiview.c b/src/obiview.c index a8fb01e..d8ffe57 100644 --- a/src/obiview.c +++ b/src/obiview.c @@ -879,18 +879,21 @@ static int update_lines(Obiview_p view, index_t line_count) // Clone the column first if needed if (!(column->writable)) { - if (clone_column_in_view(view, (((view->infos)->column_references)[i]).alias) < 0) + column = clone_column_in_view(view, (((view->infos)->column_references)[i]).alias); + if (column == NULL) { obidebug(1, "\nError cloning a column in a view when updating its line count"); return -1; } } + // Enlarge the column if needed while (line_count > (column->header)->line_count) { if (obi_enlarge_column(column) < 0) return -1; } + // Set the number of lines used to the new view line count (column->header)->lines_used = line_count; } @@ -2247,8 +2250,8 @@ int obi_view_add_column(Obiview_p view, // Save column alias strcpy((((view->infos)->column_references)[(view->infos)->column_count]).alias, alias); - // If it's the first column of the view, set the view's line count to the column's line count - if ((view->infos)->column_count == 0) + // If it's the first column of the view, set the view's line count to the column's line count, except if there's a line selection associated + if (((view->infos)->column_count == 0) && (view->line_selection == NULL)) (view->infos)->line_count = (column->header)->lines_used; // Update column count in view