Commit f4033131 authored by Morten Welinder's avatar Morten Welinder

Col/Row insert: fix undo crash with conditional formatting.

parent 9ec1369a
2014-12-06 Morten Welinder <terra@gnome.org>
* src/sheet.c (sheet_insert_rows, sheet_insert_cols): Clear style
dependents. A later step clears and re-applies style completely
for the moved area. Fixes #741197.
* src/sheet-style.c (sheet_style_clear_style_dependents): New
function.
* src/sheet.c (sheet_insert_rows, sheet_insert_cols)
(sheet_delete_cols, sheet_delete_rows): Plug leaks.
......
......@@ -12,6 +12,7 @@ Morten:
* Attempt a fix for clipboard crash. [Redhat #1160975]
* Truncate long strings for display in stf import.
* Fix crash on closing a graph sheet.
* Fix undo crash with conditional formatting and insert row. [#741197]
Thomas Kluyver:
* Fix import of extended floats from wk4 files. [#739697]
......
......@@ -326,6 +326,17 @@ rstyle_apply (GnmStyle **old, ReplacementStyle *rs, GnmRange const *r)
}
}
void
sheet_style_clear_style_dependents (Sheet *sheet, GnmRange const *r)
{
GSList *styles = sh_all_styles (sheet->style_data->style_hash);
g_slist_foreach (styles,
(GFunc)gnm_style_unlink_dependents,
r);
g_slist_free (styles);
}
/****************************************************************************/
/* If you change this, change the tile_{widths,heights} here
......
......@@ -105,6 +105,8 @@ void sheet_style_unlink (Sheet *sheet, GnmStyle *st);
void sheet_style_optimize (Sheet *sheet);
void sheet_style_clear_style_dependents (Sheet *sheet, GnmRange const *r);
G_END_DECLS
#endif /* _GNM_SHEET_STYLE_H_ */
......@@ -5133,7 +5133,6 @@ sheet_insert_cols (Sheet *sheet, int col, int count,
for (i = sheet->cols.max_used; i >= gnm_sheet_get_max_cols (sheet) - count ; --i)
sheet_col_destroy (sheet, i, TRUE);
/* 2. Fix references to and from the cells which are moving */
reloc_info.reloc_type = GNM_EXPR_RELOCATE_COLS;
reloc_info.sticky_end = TRUE;
reloc_info.origin.start.col = col;
......@@ -5145,6 +5144,10 @@ sheet_insert_cols (Sheet *sheet, int col, int count,
reloc_info.row_offset = 0;
parse_pos_init_sheet (&reloc_info.pos, sheet);
/* 1.5 Get rid of style dependents, see #741197. */
sheet_style_clear_style_dependents (sheet, &reloc_info.origin);
/* 2. Fix references to and from the cells which are moving */
combine_undo (pundo, dependents_relocate (&reloc_info));
/* 3. Move the columns to their new location (from right to left) */
......@@ -5152,6 +5155,7 @@ sheet_insert_cols (Sheet *sheet, int col, int count,
colrow_move (sheet, i, 0, i, gnm_sheet_get_last_row (sheet),
&sheet->cols, i, i + count);
/* 4. Move formatting. */
sheet_colrow_insert_finish (&reloc_info, TRUE, col, count, pundo);
add_undo_op (pundo, TRUE, sheet_delete_cols,
......@@ -5305,7 +5309,6 @@ sheet_insert_rows (Sheet *sheet, int row, int count,
for (i = sheet->rows.max_used; i >= gnm_sheet_get_max_rows (sheet) - count ; --i)
sheet_row_destroy (sheet, i, TRUE);
/* 2. Fix references to and from the cells which are moving */
reloc_info.reloc_type = GNM_EXPR_RELOCATE_ROWS;
reloc_info.sticky_end = TRUE;
reloc_info.origin.start.col = 0;
......@@ -5317,6 +5320,10 @@ sheet_insert_rows (Sheet *sheet, int row, int count,
reloc_info.row_offset = count;
parse_pos_init_sheet (&reloc_info.pos, sheet);
/* 1.5 Get rid of style dependents, see #741197. */
sheet_style_clear_style_dependents (sheet, &reloc_info.origin);
/* 2. Fix references to and from the cells which are moving */
combine_undo (pundo, dependents_relocate (&reloc_info));
/* 3. Move the rows to their new location (from last to first) */
......@@ -5324,6 +5331,7 @@ sheet_insert_rows (Sheet *sheet, int row, int count,
colrow_move (sheet, 0, i, gnm_sheet_get_last_col (sheet), i,
&sheet->rows, i, i + count);
/* 4. Move formatting. */
sheet_colrow_insert_finish (&reloc_info, FALSE, row, count, pundo);
add_undo_op (pundo, FALSE, sheet_delete_rows,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment