[gnome-control-center/gnome-3-6] background: Fix error checking in on_screenshot_finished()



commit e45e8bef748edd53681fd387eec0b73df30037f9
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Jan 30 15:35:15 2013 +0100

    background: Fix error checking in on_screenshot_finished()
    
    This could create crashers when no errors were detected, but
    either the D-Bus call or loading the pixbuf return NULL.

 panels/background/cc-background-panel.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/panels/background/cc-background-panel.c b/panels/background/cc-background-panel.c
index a7e6c55..a05e519 100644
--- a/panels/background/cc-background-panel.c
+++ b/panels/background/cc-background-panel.c
@@ -242,16 +242,17 @@ on_screenshot_finished (GObject *source,
   GdkPixbuf *pixbuf;
   cairo_surface_t *surface;
   cairo_t *cr;
+  GVariant *result;
   int width;
   int height;
   int primary;
 
   error = NULL;
-  g_dbus_connection_call_finish (panel->priv->connection,
-                                 res,
-                                 &error);
+  result = g_dbus_connection_call_finish (panel->priv->connection,
+                                          res,
+                                          &error);
 
-  if (error != NULL) {
+  if (result == NULL) {
     if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
       g_error_free (error);
       return;
@@ -262,9 +263,10 @@ on_screenshot_finished (GObject *source,
     /* fallback? */
     goto out;
   }
+  g_variant_unref (result);
 
   pixbuf = gdk_pixbuf_new_from_file (panel->priv->screenshot_path, &error);
-  if (error != NULL)
+  if (pixbuf == NULL)
     {
       g_debug ("Unable to use GNOME Shell's builtin screenshot interface: %s",
                error->message);



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