Commit 8a79de52 authored by Morten Welinder's avatar Morten Welinder

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.
parent d8e14792
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
......
......@@ -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
......
......@@ -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;
......
......@@ -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;
}
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