From: Ben Pfaff Date: Fri, 23 Mar 2012 05:04:38 +0000 (-0700) Subject: goto-case-dialog: Avoid gtk critical for invalid case number. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce9cf780b4055cf8007d0b561ce92b68c83f0b51;p=pspp 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. --- 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); } }