[gnumeric] StyleCondition: fix crash related to recalc of cell.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] StyleCondition: fix crash related to recalc of cell.
- Date: Sat, 13 Oct 2018 13:26:32 +0000 (UTC)
commit 8a79de52344ea2641ce9071bd052a780c5409687
Author: Morten Welinder <terra gnome org>
Date: Sat Oct 13 09:23:30 2018 -0400
StyleCondition: fix crash related to recalc of cell.
When a cell value is being used to determine style, make sure recalc doesn't
change the value underneath us.
Additionally, order recalc so cells precede style conditions.
ChangeLog | 8 ++++++++
NEWS | 1 +
src/dependent.c | 9 +++++++++
src/style-conditions.c | 9 +++++++--
4 files changed, 25 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index afaba788d..5c3e473e5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2018-10-13 Morten Welinder <terra gnome org>
+
+ * src/dependent.c (workbook_recalc): Evaluate cells before other
+ deps.
+
+ * src/style-conditions.c (gnm_style_conditions_eval): Copy the
+ cell value; it may change due to recalc.
+
2018-10-04 Morten Welinder <terra gnome org>
* src/sheet-filter.c (gnm_sheet_filter_insdel_colrow): Shorten
diff --git a/NEWS b/NEWS
index 5c90f9e85..cc6c3152d 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ Morten:
* Fix problem reading really old xls format.
* Fix sheet filter problem. [#359]
* New NT_RADICAL function.
+ * Fix conditional style crash.
--------------------------------------------------------------------------
Gnumeric 1.12.43
diff --git a/src/dependent.c b/src/dependent.c
index 217e6c08a..f19486e2f 100644
--- a/src/dependent.c
+++ b/src/dependent.c
@@ -2865,6 +2865,15 @@ workbook_recalc (Workbook *wb)
gnm_app_recalc_start ();
+ // Do a pass computing only cells; this allows style deps to see
+ // updated values as needed.
+ WORKBOOK_FOREACH_DEPENDENT (wb, dep, {
+ if (dependent_is_cell (dep) && dependent_needs_recalc (dep)) {
+ redraw = TRUE;
+ dependent_eval (dep);
+ }
+ });
+
WORKBOOK_FOREACH_DEPENDENT (wb, dep, {
if (dependent_needs_recalc (dep)) {
redraw = TRUE;
diff --git a/src/style-conditions.c b/src/style-conditions.c
index 9f8ec167c..0769bb18c 100644
--- a/src/style-conditions.c
+++ b/src/style-conditions.c
@@ -978,12 +978,15 @@ gnm_style_conditions_eval (GnmStyleConditions const *sc, GnmEvalPos const *ep)
{
unsigned i;
GPtrArray const *conds;
- GnmCell const *cell = sheet_cell_get (ep->sheet, ep->eval.col, ep->eval.row);
- GnmValue const *cv = cell ? cell->value : NULL;
+ GnmCell *cell;
+ GnmValue *cv;
g_return_val_if_fail (sc != NULL, -1);
g_return_val_if_fail (sc->conditions != NULL, -1);
+ cell = sheet_cell_get (ep->sheet, ep->eval.col, ep->eval.row);
+ cv = value_dup (cell->value);
+
conds = sc->conditions;
if (debug_style_conds ()) {
@@ -1003,6 +1006,7 @@ gnm_style_conditions_eval (GnmStyleConditions const *sc, GnmEvalPos const *ep)
if (use_this) {
if (debug_style_conds ())
g_printerr (" Using clause %d\n", i);
+ value_release (cv);
return i;
}
}
@@ -1010,5 +1014,6 @@ gnm_style_conditions_eval (GnmStyleConditions const *sc, GnmEvalPos const *ep)
if (debug_style_conds ())
g_printerr (" No matching clauses\n");
+ value_release (cv);
return -1;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]