[gnome-control-center] Don't crash if accounts service policy is not available



commit 2874efc7f1ae88283d75c07cf734909f855f24a1
Author: William Jon McCann <jmccann redhat com>
Date:   Sat Oct 30 18:04:48 2010 -0400

    Don't crash if accounts service policy is not available

 panels/user-accounts/um-login-options.c |   18 ++++++++++--------
 panels/user-accounts/um-user-panel.c    |   25 +++++++++++++++----------
 2 files changed, 25 insertions(+), 18 deletions(-)
---
diff --git a/panels/user-accounts/um-login-options.c b/panels/user-accounts/um-login-options.c
index 99b57ce..75204ec 100644
--- a/panels/user-accounts/um-login-options.c
+++ b/panels/user-accounts/um-login-options.c
@@ -390,14 +390,16 @@ um_login_options_new (GtkBuilder *builder)
                           G_CALLBACK (update_login_options), um);
 
         um->permission = polkit_permission_new_sync ("org.freedesktop.accounts.set-login-option", NULL, NULL, NULL);
-        widget = um_lock_button_new (um->permission);
-        gtk_widget_show (widget);
-        box = (GtkWidget *)gtk_builder_get_object (builder, "lockbutton-alignment");
-        gtk_container_add (GTK_CONTAINER (box), widget);
-        g_signal_connect (widget, "changed",
-                          G_CALLBACK (lockbutton_changed), um);
-        lockbutton_changed (UM_LOCK_BUTTON (widget), um);
-        um->lock_button = widget;
+        if (um->permission != NULL) {
+                widget = um_lock_button_new (um->permission);
+                gtk_widget_show (widget);
+                box = (GtkWidget *)gtk_builder_get_object (builder, "lockbutton-alignment");
+                gtk_container_add (GTK_CONTAINER (box), widget);
+                g_signal_connect (widget, "changed",
+                                  G_CALLBACK (lockbutton_changed), um);
+                lockbutton_changed (UM_LOCK_BUTTON (widget), um);
+                um->lock_button = widget;
+        }
 
         error = NULL;
         um->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
diff --git a/panels/user-accounts/um-user-panel.c b/panels/user-accounts/um-user-panel.c
index 4bb3d6e..93c7a7e 100644
--- a/panels/user-accounts/um-user-panel.c
+++ b/panels/user-accounts/um-user-panel.c
@@ -558,7 +558,9 @@ selected_user_changed (GtkTreeSelection *selection, UmUserPanelPrivate *d)
         if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
                 gtk_tree_model_get (model, &iter, USER_COL, &user, -1);
                 show_user (user, d);
-                lockbutton_changed (UM_LOCK_BUTTON (d->lock_button), d);
+                if (d->lock_button != NULL) {
+                        lockbutton_changed (UM_LOCK_BUTTON (d->lock_button), d);
+                }
                 g_object_unref (user);
         }
 }
@@ -1153,15 +1155,18 @@ setup_main_window (UmUserPanelPrivate *d)
                           G_CALLBACK (change_fingerprint), d);
 
         d->permission = polkit_permission_new_sync ("org.freedesktop.accounts.user-administration", NULL, NULL, NULL);
-        button = um_lock_button_new (d->permission);
-        gtk_widget_set_margin_top (button, 12);
-        gtk_widget_show (button);
-        box = get_widget (d, "userlist-vbox");
-        gtk_box_pack_end (GTK_BOX (box), button, FALSE, FALSE, 0);
-        g_signal_connect (button, "changed",
-                          G_CALLBACK (lockbutton_changed), d);
-        lockbutton_changed (UM_LOCK_BUTTON (button), d);
-        d->lock_button = button;
+        if (d->permission != NULL) {
+                /* accounts service not available? */
+                button = um_lock_button_new (d->permission);
+                gtk_widget_set_margin_top (button, 12);
+                gtk_widget_show (button);
+                box = get_widget (d, "userlist-vbox");
+                gtk_box_pack_end (GTK_BOX (box), button, FALSE, FALSE, 0);
+                g_signal_connect (button, "changed",
+                                  G_CALLBACK (lockbutton_changed), d);
+                lockbutton_changed (UM_LOCK_BUTTON (button), d);
+                d->lock_button = button;
+        }
 
         button = get_widget (d, "add-user-button");
         names[0] = "changes-prevent-symbolic";



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