cheese r595 - in branches/gnome-2-22: . src



Author: dgsiegel
Date: Thu Mar 13 12:38:22 2008
New Revision: 595
URL: http://svn.gnome.org/viewvc/cheese?rev=595&view=rev

Log:
cheese crashes if getting information from a webcam fails, courtesy of Sjoerd Simons, fixes bug #522197


Modified:
   branches/gnome-2-22/ChangeLog
   branches/gnome-2-22/src/cheese-webcam.c

Modified: branches/gnome-2-22/src/cheese-webcam.c
==============================================================================
--- branches/gnome-2-22/src/cheese-webcam.c	(original)
+++ branches/gnome-2-22/src/cheese-webcam.c	Thu Mar 13 12:38:22 2008
@@ -562,11 +562,10 @@
   CheeseWebcamPrivate* priv = CHEESE_WEBCAM_GET_PRIVATE (webcam);
   GError *err = NULL;
   char *webcam_input;
-  
+
   if (priv->num_webcam_devices == 0)
   {
-    priv->webcam_source_bin = gst_parse_bin_from_description ("videotestsrc name=video_source",
-                                                              TRUE, &err);
+    goto fallback;
   }
   else
   {
@@ -588,12 +587,16 @@
     format = &(g_array_index (selected_webcam->video_formats, CheeseVideoFormat, 0));
     for (i = 1; i < selected_webcam->num_video_formats; i++)
     {
-      
+
       if (g_array_index (selected_webcam->video_formats, CheeseVideoFormat, i).width >  format->width)
       {
         format = &(g_array_index (selected_webcam->video_formats, CheeseVideoFormat, i));
       }
     }
+
+    if (format == NULL)
+      goto fallback;
+
     /* Select the highest framerate up to 30 Hz*/
     framerate_numerator = 1;
     framerate_denominator = 1;
@@ -620,15 +623,29 @@
 
     priv->webcam_source_bin = gst_parse_bin_from_description (webcam_input,
                                                               TRUE, &err);
-    g_free (webcam_input);    
+    g_free (webcam_input);
+
+    if ( priv->webcam_source_bin == NULL)
+      goto fallback;
   }
+
+  priv->video_source = gst_bin_get_by_name (GST_BIN (priv->webcam_source_bin), "video_source");
+  return TRUE;
+
+fallback:
   if (err != NULL)
   {
     g_error_free (err);
-    return FALSE;
+    err = NULL;
   }
 
-  priv->video_source = gst_bin_get_by_name (GST_BIN (priv->webcam_source_bin), "video_source");
+  priv->webcam_source_bin = gst_parse_bin_from_description ("videotestsrc name=video_source",
+                                                              TRUE, &err);
+  if (err != NULL)
+  {
+    g_error_free (err);
+    return FALSE;
+  }
   return TRUE;
 }
 



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