variable: Only notify variable width change if it really did change.
authorBen Pfaff <blp@cs.stanford.edu>
Sat, 28 Sep 2013 23:03:32 +0000 (16:03 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Sat, 28 Sep 2013 23:03:32 +0000 (16:03 -0700)
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

index 9f21b1497be391e5a1ea635a61f7d7d9602b8085..72dd2d8ef6b698fb44c417fe4e1691ca3a13ad9f 100644 (file)
@@ -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.