From: John Darrington Date: Thu, 6 May 2010 15:12:58 +0000 (+0200) Subject: Fix crash on variable type dialog custom currency display. X-Git-Tag: v0.7.5~37 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pspp-builds.git;a=commitdiff_plain;h=00ffc59ef40cb0bc7d1db6f22fd100ef882a5229 Fix crash on variable type dialog custom currency display. Fixed a bug where a null pointer dereference occured when the user chose the custom currency button in the variable type dialog. --- diff --git a/src/ui/gui/psppire-var-sheet.c b/src/ui/gui/psppire-var-sheet.c index 920d84e4..48f34f6d 100644 --- a/src/ui/gui/psppire-var-sheet.c +++ b/src/ui/gui/psppire-var-sheet.c @@ -487,7 +487,8 @@ psppire_var_sheet_realize (GtkWidget *w) PSPPIRE_VAR_STORE (psppire_sheet_get_model (PSPPIRE_SHEET (vs)))); vs->missing_val_dialog = missing_val_dialog_create (GTK_WINDOW (toplevel)); - vs->var_type_dialog = var_type_dialog_create (GTK_WINDOW (toplevel)); + vs->var_type_dialog = var_type_dialog_create (GTK_WINDOW (toplevel), + PSPPIRE_VAR_STORE (psppire_sheet_get_model (PSPPIRE_SHEET (vs)))); /* Chain up to the parent class */ GTK_WIDGET_CLASS (parent_class)->realize (w); diff --git a/src/ui/gui/var-type-dialog.c b/src/ui/gui/var-type-dialog.c index 5ba028d4..f196e554 100644 --- a/src/ui/gui/var-type-dialog.c +++ b/src/ui/gui/var-type-dialog.c @@ -262,12 +262,12 @@ preview_custom (GtkWidget *w, gpointer data) union value v; v.f = 1234.56; - sample_text = value_to_text (v, NULL, dialog->fmt_l); + sample_text = value_to_text (v, dialog->vs->dictionary, dialog->fmt_l); gtk_label_set_text (GTK_LABEL (dialog->label_psample), sample_text); g_free (sample_text); v.f = -v.f; - sample_text = value_to_text (v, NULL, dialog->fmt_l); + sample_text = value_to_text (v, dialog->vs->dictionary, dialog->fmt_l); gtk_label_set_text (GTK_LABEL (dialog->label_nsample), sample_text); g_free (sample_text); } @@ -315,21 +315,20 @@ set_format_type_from_treeview (GtkTreeView *treeview, gpointer data) dialog->fmt_l = custom_format; dialog->fmt_l.type = *(int*) g_value_get_pointer (&the_value); - } - - /* Create the structure */ struct var_type_dialog * -var_type_dialog_create (GtkWindow *toplevel) +var_type_dialog_create (GtkWindow *toplevel, PsppireVarStore *vs) { gint i; struct var_type_dialog *dialog = g_malloc (sizeof (struct var_type_dialog)); GtkBuilder *xml = builder_new ("var-sheet-dialogs.ui"); + dialog->vs = vs; + dialog->window = get_widget_assert (xml,"var_type_dialog"); dialog->active_button = -1; diff --git a/src/ui/gui/var-type-dialog.h b/src/ui/gui/var-type-dialog.h index 8acfea11..4bb681aa 100644 --- a/src/ui/gui/var-type-dialog.h +++ b/src/ui/gui/var-type-dialog.h @@ -20,6 +20,8 @@ #include +#include "psppire-var-store.h" + /* This module describes the behaviour of the Variable Type dialog box, used for input of the variable type parameter in the var sheet */ @@ -44,6 +46,10 @@ struct var_type_dialog /* Variable to be updated */ struct variable *pv; + + /* The variable store to which this dialog relates */ + PsppireVarStore *vs; + /* Local copy of format specifier */ struct fmt_spec fmt_l; @@ -82,7 +88,7 @@ struct var_type_dialog }; -struct var_type_dialog * var_type_dialog_create (GtkWindow *); +struct var_type_dialog * var_type_dialog_create (GtkWindow *, PsppireVarStore *vs); void var_type_dialog_show (struct var_type_dialog *dialog);