From 61bf4a044aafdca09f4b2c363b6636d44e93d215 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 28 Sep 2013 16:03:32 -0700 Subject: [PATCH] variable: Only notify variable width change if it really did change. This code was notifying a width change every time, even if the width did not really change, which is wasteful. This had a side effect of revealing a bug in the GUI code which caused an assertion failure. The bug still remains in the GUI code, though it is now slightly harder to trigger, and will be fixed separately in an upcoming commit. --- src/data/variable.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/data/variable.c b/src/data/variable.c index 9f21b1497b..72dd2d8ef6 100644 --- a/src/data/variable.c +++ b/src/data/variable.c @@ -285,8 +285,11 @@ var_set_width_and_formats (struct variable *v, int new_width, if (fmt_resize (&v->write, new_width)) traits |= VAR_TRAIT_WRITE_FORMAT; - v->width = new_width; - traits |= VAR_TRAIT_WIDTH; + if (v->width != new_width) + { + v->width = new_width; + traits |= VAR_TRAIT_WIDTH; + } if (print) { @@ -300,7 +303,8 @@ var_set_width_and_formats (struct variable *v, int new_width, traits |= VAR_TRAIT_WRITE_FORMAT; } - dict_var_changed (v, traits, ov); + if (traits != 0) + dict_var_changed (v, traits, ov); } /* Changes the width of V to NEW_WIDTH. -- 2.30.2