[gnumeric] Conditional Formats: fix inter-process paste crash.



commit 44c0d0e4ea1276954619484345e5ed04c9d8af61
Author: Morten Welinder <terra gnome org>
Date:   Thu Jun 27 13:48:55 2019 -0400

    Conditional Formats: fix inter-process paste crash.

 ChangeLog       |  5 +++++
 NEWS            |  1 +
 src/clipboard.c | 27 +++++++++++++++++++++++++++
 3 files changed, 33 insertions(+)
---
diff --git a/ChangeLog b/ChangeLog
index 41c71fff0..86058b6eb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2019-06-27  Morten Welinder  <terra gnome org>
+
+       * src/clipboard.c (cellregion_invalidate_sheet): Also invalidate
+       conditional formats that reference the sheet.
+
 2019-06-20  Morten Welinder  <terra gnome org>
 
        * configure.ac (lgamma_r): Check if we must prototype lgamma_r
diff --git a/NEWS b/NEWS
index 3492fa116..5e4765df7 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ Gnumeric 1.12.46
 Morten:
        * Fix over-eager guessing of dates in csv.  [#401]
        * Fix Mac build problem.  [#402]
+       * Fix inter-process paste crash [#406]
 
 --------------------------------------------------------------------------
 Gnumeric 1.12.45
diff --git a/src/clipboard.c b/src/clipboard.c
index 683029a6d..2310585cb 100644
--- a/src/clipboard.c
+++ b/src/clipboard.c
@@ -37,6 +37,7 @@
 #include <expr.h>
 #include <value.h>
 #include <mstyle.h>
+#include <style-conditions.h>
 #include <stf-parse.h>
 #include <gnm-format.h>
 #include <sheet-object-cell-comment.h>
@@ -1010,6 +1011,7 @@ cellregion_invalidate_sheet (GnmCellRegion *cr,
        GSList *ptr;
        gboolean save_invalidated;
        GnmExprRelocateInfo rinfo;
+       GnmStyleList *l;
 
        g_return_if_fail (cr != NULL);
        g_return_if_fail (IS_SHEET (sheet));
@@ -1023,6 +1025,31 @@ cellregion_invalidate_sheet (GnmCellRegion *cr,
                        (GHFunc)cb_invalidate_cellcopy, &rinfo);
        sheet->being_invalidated = save_invalidated;
 
+       // Remove conditional formats from styles.  That's brutal, but
+       // they reference the sheet.  See #406.
+       for (l = cr->styles; l; l = l->next) {
+               GnmStyleRegion *sr = l->data;
+               GnmRange const *r = &sr->range;
+               GnmStyle const *style = sr->style;
+               GnmStyleConditions *conds = gnm_style_is_element_set (style, MSTYLE_CONDITIONS)
+                       ? gnm_style_get_conditions (style)
+                       : NULL;
+
+               if (conds &&
+                   gnm_style_conditions_get_sheet (conds) == sheet) {
+                       GnmStyle *style2;
+                       GnmStyleRegion *sr2;
+
+                       style2 = gnm_style_dup (style);
+                       gnm_style_set_conditions (style2, NULL);
+                       sr2 = gnm_style_region_new (r, style2);
+                       gnm_style_unref (style2);
+
+                       gnm_style_region_free (sr);
+                       l->data = sr2;
+               }
+       }
+
        for (ptr = cr->objects; ptr != NULL ; ptr = ptr->next)
                sheet_object_invalidate_sheet (ptr->data, sheet);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]