If picture does no exist, warn and exit master
authorThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Sat, 16 Aug 2008 23:00:15 +0000 (20:00 -0300)
committerThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Sat, 16 Aug 2008 23:00:15 +0000 (20:00 -0300)
gdk.c

diff --git a/gdk.c b/gdk.c
index 11c277f..d9ed4cd 100644 (file)
--- a/gdk.c
+++ b/gdk.c
@@ -119,6 +119,7 @@ main (int argc, char **argv)
   GdkColor Yellow;
   GdkColor Black;
   PangoAttribute *attr;
+  GError *error;
   gtk_init (&argc, &argv);
   if (argc < 3)
     {
@@ -132,7 +133,15 @@ main (int argc, char **argv)
   ctx.points = ReadPoints (dotsfile);
   ctx.points = drop_dup_frames (ctx.points, FPF);
   rescale_points (ctx.points, get_scales (FPF));
-  ctx.picture = gdk_pixbuf_new_from_file (filename, NULL);
+  error = NULL;
+  ctx.picture = gdk_pixbuf_new_from_file (filename, &error);
+  if (ctx.picture == NULL)
+    {
+      fprintf (stderr, "Could not open picture %s: %s\n", filename,
+               error->message);
+      g_error_free (error);
+      exit (1);
+    }
   ctx.i = ctx.points->len;
   colorspace = gdk_pixbuf_get_colorspace (ctx.picture);
   has_alpha = gdk_pixbuf_get_has_alpha (ctx.picture);