X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fdictionary.c;fp=src%2Fdata%2Fdictionary.c;h=427cae3669eb695ef282650965ebb5df0ca4cb23;hb=d01a4986ffc8f5afa5ee7d29dd7233143b6de7ec;hp=2a5f4d83e78846f8b9e5371515a68bdda875750d;hpb=5a9ba397926090eca1fbef3f004def23c3f1f1c7;p=pspp diff --git a/src/data/dictionary.c b/src/data/dictionary.c index 2a5f4d83e7..427cae3669 100644 --- a/src/data/dictionary.c +++ b/src/data/dictionary.c @@ -1114,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);