From ce9cf780b4055cf8007d0b561ce92b68c83f0b51 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Thu, 22 Mar 2012 22:04:38 -0700 Subject: [PATCH] goto-case-dialog: Avoid gtk critical for invalid case number. I noticed this when Go To Case was invoked with an empty data sheet, in which case the default case number is the invalid case number 0. --- src/ui/gui/goto-case-dialog.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ui/gui/goto-case-dialog.c b/src/ui/gui/goto-case-dialog.c index ad10b25686..282f416368 100644 --- a/src/ui/gui/goto-case-dialog.c +++ b/src/ui/gui/goto-case-dialog.c @@ -53,6 +53,7 @@ goto_case_dialog (PsppireDataSheet *ds) if ( response == PSPPIRE_RESPONSE_GOTO ) { + PsppireDataStore *data_store = psppire_data_sheet_get_data_store (ds); glong case_num; GtkWidget *case_num_entry = get_widget_assert (xml, "goto-case-case-num-entry"); @@ -60,6 +61,8 @@ goto_case_dialog (PsppireDataSheet *ds) case_num = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (case_num_entry)) - FIRST_CASE_NUMBER ; - psppire_data_sheet_goto_case (ds, case_num); + if (case_num >= 0 + && case_num < psppire_data_store_get_case_count (data_store)) + psppire_data_sheet_goto_case (ds, case_num); } } -- 2.30.2