[PATCH] Make AisleRiot not segv on missing pixmaps



Here's a patch to let aisleriot tell the user that something's wrong
(instead of crashing) if the deck images aren't where aisleriot
expects them to be.

-- 
Best of luck,
Mark Schreiber
Index: aisleriot/card.c
===================================================================
RCS file: /cvs/gnome/gnome-games/aisleriot/card.c,v
retrieving revision 1.20
diff -u -r1.20 card.c
--- aisleriot/card.c	19 Jun 2003 08:31:30 -0000	1.20
+++ aisleriot/card.c	26 Oct 2003 22:54:16 -0000
@@ -115,6 +115,14 @@
 void load_pixmaps (GtkWidget* app, GdkCardDeckOptions deck_options) 
 {
   card_deck = gdk_card_deck_new (app->window, deck_options);
+  if (card_deck == NULL) {
+	  GtkWidget * error_dialog;
+	  
+	  error_dialog = gtk_message_dialog_new(app, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, N_("AisleRiot could not load its deck images.\n\nAisleRiot will now exit."));
+	  gtk_dialog_run (GTK_DIALOG (error_dialog));
+	  gtk_widget_destroy(error_dialog);
+	  exit(1);
+  }
   mask = gdk_card_deck_mask (GDK_CARD_DECK (card_deck)); 
   slot_pixbuf = get_pixbuf ("cards/slots/plain.png");
   default_background_pixmap = get_pixmap ("cards/baize.png");
Index: gdk-card-image/gdk-card-image.c
===================================================================
RCS file: /cvs/gnome/gnome-games/gdk-card-image/gdk-card-image.c,v
retrieving revision 1.5
diff -u -r1.5 gdk-card-image.c
--- gdk-card-image/gdk-card-image.c	21 Jun 2003 07:14:50 -0000	1.5
+++ gdk-card-image/gdk-card-image.c	26 Oct 2003 22:54:16 -0000
@@ -759,6 +759,7 @@
   resolve_options (option_data, deck_options, w->index);
 
   for (i = 0; i < OPT_NUM; i++) {
+	  g_return_val_if_fail(w->index[i] != -1, NULL);
     file[i] = &option_data[i].dir->file[w->index[i]];
     gdk_card_deck_file_load (file[i]);
   }

Attachment: pgpYIcyB66uNr.pgp
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]