[gnumeric] Col/Row insert: fix undo crash with conditional formatting.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Col/Row insert: fix undo crash with conditional formatting.
- Date: Sat, 6 Dec 2014 18:34:30 +0000 (UTC)
commit f40331313f3c885647ef6b2aa1644a9aaa6bf0a1
Author: Morten Welinder <terra gnome org>
Date: Sat Dec 6 13:33:56 2014 -0500
Col/Row insert: fix undo crash with conditional formatting.
ChangeLog | 7 +++++++
NEWS | 1 +
src/sheet-style.c | 11 +++++++++++
src/sheet-style.h | 2 ++
src/sheet.c | 12 ++++++++++--
5 files changed, 31 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 7cf0c97..7f875e2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
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.
diff --git a/NEWS b/NEWS
index 299847b..9e9f30c 100644
--- a/NEWS
+++ b/NEWS
@@ -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]
diff --git a/src/sheet-style.c b/src/sheet-style.c
index b97c260..bfd2ad4 100644
--- a/src/sheet-style.c
+++ b/src/sheet-style.c
@@ -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
diff --git a/src/sheet-style.h b/src/sheet-style.h
index 0fd91f4..226a83f 100644
--- a/src/sheet-style.h
+++ b/src/sheet-style.h
@@ -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_ */
diff --git a/src/sheet.c b/src/sheet.c
index aa53a87..4eb128c 100644
--- a/src/sheet.c
+++ b/src/sheet.c
@@ -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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]