Don't crash when resizing columns with no associated variable
authorJohn Darrington <john@darrington.wattle.id.au>
Mon, 8 Dec 2008 11:26:56 +0000 (20:26 +0900)
committerJohn Darrington <john@darrington.wattle.id.au>
Mon, 8 Dec 2008 11:26:56 +0000 (20:26 +0900)
src/ui/gui/psppire-data-editor.c
src/ui/gui/psppire-dict.c

index 0fe4f68091b1d8395d8d7c8e0e1c437b56035e63..92250255f501eea0316a023dc44709d7309961c7 100644 (file)
@@ -274,6 +274,9 @@ rewidth_variable (GtkWidget *w, gint unit, glong size)
   const PsppireDict *dict = de->data_store->dict;
   struct variable *var = psppire_dict_get_variable (dict, unit);
 
+  if (NULL == var)
+    return;
+
   var_set_display_width (var, size / (float) width_of_m (w));
 }
 
index 4572ba0b6ef7bff91ec0026995b29676c7257fab..090ad90c5e8223a9efe4b19fb7b90bfbf40c2867 100644 (file)
@@ -434,7 +434,9 @@ psppire_dict_set_name (PsppireDict* d, gint idx, const gchar *name)
 
 
 
-/* Return the IDXth variable */
+/* Return the IDXth variable.
+   Will return NULL if IDX  exceeds the number of variables in the dictionary.
+ */
 struct variable *
 psppire_dict_get_variable (const PsppireDict *d, gint idx)
 {