goto-case-dialog: Avoid gtk critical for invalid case number.
authorBen Pfaff <blp@cs.stanford.edu>
Fri, 23 Mar 2012 05:04:38 +0000 (22:04 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Tue, 26 Jun 2012 03:27:09 +0000 (20:27 -0700)
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

index ad10b256868cd4ab5c82ba0531073dc9869733e3..282f41636883c21315d1f21d6ed08cfa1903a922 100644 (file)
@@ -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);
     }
 }