[gnome-settings-daemon] color: Fix a crash when cancelling setting up screens



commit 5fad0bb3c3ff95f436faa1235a5a5fdaf16ad2f7
Author: Richard Hughes <richard hughsie com>
Date:   Tue Mar 15 15:38:22 2016 +0000

    color: Fix a crash when cancelling setting up screens
    
    https://bugzilla.gnome.org/show_bug.cgi?id=763382

 plugins/color/gsd-color-state.c |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/plugins/color/gsd-color-state.c b/plugins/color/gsd-color-state.c
index 948ee07..061e414 100644
--- a/plugins/color/gsd-color-state.c
+++ b/plugins/color/gsd-color-state.c
@@ -1358,10 +1358,18 @@ on_rr_screen_acquired (GObject      *object,
         GsdColorState *state = data;
         GsdColorStatePrivate *priv = state->priv;
         GnomeRRScreen *screen;
+        GError *error = NULL;
 
-        screen = gnome_rr_screen_new_finish (result, NULL);
-        if (!screen)
-                return;
+        /* gnome_rr_screen_new_async() does not take a GCancellable */
+        if (g_cancellable_is_cancelled (priv->cancellable))
+                goto out;
+
+        screen = gnome_rr_screen_new_finish (result, &error);
+        if (screen == NULL) {
+                g_warning ("failed to get screens: %s", error->message);
+                g_error_free (error);
+                goto out;
+        }
 
         priv->state_screen = screen;
 
@@ -1369,6 +1377,9 @@ on_rr_screen_acquired (GObject      *object,
                            priv->cancellable,
                            gcm_session_client_connect_cb,
                            state);
+out:
+        /* manually added */
+        g_object_unref (state);
 }
 
 void
@@ -1384,7 +1395,7 @@ gsd_color_state_start (GsdColorState *state)
         /* coldplug the list of screens */
         gnome_rr_screen_new_async (gdk_screen_get_default (),
                                    on_rr_screen_acquired,
-                                   state);
+                                   g_object_ref (state));
 }
 
 void


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