From b7efb0befa9d8b141c4ddac54c194bc4f94f4134 Mon Sep 17 00:00:00 2001 From: Chris Toshok Date: Mon, 4 Dec 2000 09:59:31 +0000 Subject: need to zero out the bits corresponding to the rows not selected in the 2000-12-04 Chris Toshok * e-table-selection-model.c (e_table_selection_model_select_all): need to zero out the bits corresponding to the rows not selected in the last full 32 bit mask. This fixes a crash in the subscribe UI (or potentially anywhere that uses selection_model_select_all/selection_model_foreach.) svn path=/trunk/; revision=6770 --- widgets/table/e-table-selection-model.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'widgets') diff --git a/widgets/table/e-table-selection-model.c b/widgets/table/e-table-selection-model.c index e8f5dcd38f..d39e7b3c14 100644 --- a/widgets/table/e-table-selection-model.c +++ b/widgets/table/e-table-selection-model.c @@ -524,7 +524,19 @@ e_table_selection_model_select_all (ETableSelectionModel *selection) for (i = 0; i < (selection->row_count + 31) / 32; i ++) { selection->selection[i] = ONES; } - + + /* need to zero out the bits corresponding to the rows not + selected in the last full 32 bit mask */ + if (selection->row_count % 32) { + int unselected_mask = 0; + int num_unselected_in_last_byte = 32 - selection->row_count % 32; + + for (i = 0; i < num_unselected_in_last_byte; i ++) + unselected_mask |= 1 << i; + + selection->selection[(selection->row_count + 31) / 32 - 1] &= ~unselected_mask; + } + selection->cursor_col = 0; selection->cursor_row = 0; selection->selection_start_row = 0; -- cgit v1.2.3