cairo: Fix font scaling.
[pspp] / src / data / dictionary.c
index d34bd9a358214e19353ad7793d9f66cc1311a3c3..427cae3669eb695ef282650965ebb5df0ca4cb23 100644 (file)
@@ -1072,6 +1072,13 @@ dict_get_case_weight (const struct dictionary *d, const struct ccase *c,
     }
 }
 
+/* Returns the format to use for weights. */
+const struct fmt_spec *
+dict_get_weight_format (const struct dictionary *d)
+{
+  return d->weight ? var_get_print_format (d->weight) : &F_8_0;
+}
+
 /* Sets the weighting variable of D to V, or turning off
    weighting if V is a null pointer. */
 void
@@ -1107,6 +1114,22 @@ dict_set_filter (struct dictionary *d, struct variable *v)
   assert (v == NULL || dict_contains_var (d, v));
   assert (v == NULL || var_is_numeric (v));
 
+  /* When a filter is set, we ref the dictionary.
+     This is because the GUI maintains a pointer
+     to the dict's variables, and the variables'
+     addresses change in the callback.  */
+  if (d->filter == NULL && v != NULL)
+    {
+      d = dict_ref (d);
+    }
+
+  /* Deref the dict when a filter is removed.  */
+  if (d->filter != NULL && v == NULL)
+    {
+      assert (d->ref_cnt > 0);
+      dict_unref (d);
+    }
+
   d->filter = v;
 
   if (d->changed) d->changed (d, d->changed_data);