From 59595479e350bd597b33217259f8cf996b3595b2 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Mon, 8 Dec 2008 20:26:56 +0900 Subject: [PATCH] Don't crash when resizing columns with no associated variable --- src/ui/gui/psppire-data-editor.c | 3 +++ src/ui/gui/psppire-dict.c | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ui/gui/psppire-data-editor.c b/src/ui/gui/psppire-data-editor.c index 0fe4f680..92250255 100644 --- a/src/ui/gui/psppire-data-editor.c +++ b/src/ui/gui/psppire-data-editor.c @@ -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)); } diff --git a/src/ui/gui/psppire-dict.c b/src/ui/gui/psppire-dict.c index 4572ba0b..090ad90c 100644 --- a/src/ui/gui/psppire-dict.c +++ b/src/ui/gui/psppire-dict.c @@ -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) { -- 2.30.2