[accounts-dialog] Make login options work
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [accounts-dialog] Make login options work
- Date: Fri, 26 Mar 2010 05:52:26 +0000 (UTC)
commit 941867c77544b528887aa0e7b6a0cd97194c5800
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Mar 25 23:14:20 2010 -0400
Make login options work
There were various refcounting and memory handling issues that
made this crash after a few cycles.
src/main.c | 6 ++++++
src/um-login-options.c | 16 +++++++++-------
src/um-photo-dialog.c | 2 +-
src/um-user-manager.c | 12 ++++++------
4 files changed, 22 insertions(+), 14 deletions(-)
---
diff --git a/src/main.c b/src/main.c
index d78d0f7..5aab048 100644
--- a/src/main.c
+++ b/src/main.c
@@ -268,9 +268,13 @@ user_changed (UmUserManager *um, UmUser *user, UserAccountDialog *d)
-1);
g_object_unref (pixbuf);
g_free (text);
+ g_object_unref (current);
break;
}
+ if (current)
+ g_object_unref (current);
+
} while (gtk_tree_model_iter_next (model, &iter));
if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
@@ -279,6 +283,8 @@ user_changed (UmUserManager *um, UmUser *user, UserAccountDialog *d)
if (current == user) {
show_user (user, d);
}
+ if (current)
+ g_object_unref (current);
}
}
diff --git a/src/um-login-options.c b/src/um-login-options.c
index 8c02879..54c24e5 100644
--- a/src/um-login-options.c
+++ b/src/um-login-options.c
@@ -102,7 +102,7 @@ user_added (UmUserManager *um, UmUser *user, UmLoginOptions *d)
store = (GtkListStore*)gtk_combo_box_get_model (combo);
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
- AUTOLOGIN_NAME_COL, um_user_get_real_name (user),
+ AUTOLOGIN_NAME_COL, um_user_get_display_name (user),
AUTOLOGIN_USER_COL, user,
-1);
@@ -285,7 +285,6 @@ update_autologin (GtkWidget *widget,
GtkComboBox *combo = GTK_COMBO_BOX (widget);
GtkTreeModel *model;
GtkTreeIter iter;
- UmUserManager *manager;
UmUser *user;
gboolean enabled;
@@ -300,13 +299,13 @@ update_autologin (GtkWidget *widget,
}
else {
enabled = FALSE;
-
- manager = um_user_manager_ref_default ();
- user = um_user_manager_get_user_by_id (manager, getuid ());
- g_object_unref (manager);
+ user = um_user_manager_get_user_by_id (d->manager, getuid ());
+ g_object_ref (user);
}
um_user_set_automatic_login (user, enabled);
+
+ g_object_unref (user);
}
static void
@@ -349,7 +348,10 @@ um_login_options_new (GtkBuilder *builder)
store = gtk_list_store_new (2, G_TYPE_STRING, UM_TYPE_USER);
gtk_combo_box_set_model (GTK_COMBO_BOX (widget), GTK_TREE_MODEL (store));
gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter, 0, _("Disabled"), 1, NULL, -1);
+ gtk_list_store_set (store, &iter,
+ AUTOLOGIN_NAME_COL, _("Disabled"),
+ AUTOLOGIN_USER_COL, NULL,
+ -1);
gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
diff --git a/src/um-photo-dialog.c b/src/um-photo-dialog.c
index 40ff3ec..df501f8 100644
--- a/src/um-photo-dialog.c
+++ b/src/um-photo-dialog.c
@@ -651,7 +651,7 @@ um_photo_dialog_set_user (UmPhotoDialog *um,
um->user = user;
if (um->user) {
- g_object_ref (user);
+ g_object_ref (um->user);
children = gtk_container_get_children (GTK_CONTAINER (um->photo_popup));
g_list_foreach (children, (GFunc) clear_tip, NULL);
diff --git a/src/um-user-manager.c b/src/um-user-manager.c
index f611051..1e39018 100644
--- a/src/um-user-manager.c
+++ b/src/um-user-manager.c
@@ -198,7 +198,7 @@ user_added_handler (DBusGProxy *proxy,
{
UmUserManager *manager = UM_USER_MANAGER (user_data);
UmUser *user;
-
+
if (g_hash_table_lookup (manager->user_by_object_path, object_path))
return;
@@ -210,8 +210,8 @@ user_added_handler (DBusGProxy *proxy,
g_signal_connect (user, "changed",
G_CALLBACK (user_changed_handler), manager);
- g_hash_table_insert (manager->user_by_object_path, (gpointer)um_user_get_object_path (user), g_object_ref (user));
- g_hash_table_insert (manager->user_by_name, (gpointer)um_user_get_user_name (user), g_object_ref (user));
+ g_hash_table_insert (manager->user_by_object_path, g_strdup (um_user_get_object_path (user)), g_object_ref (user));
+ g_hash_table_insert (manager->user_by_name, g_strdup (um_user_get_user_name (user)), g_object_ref (user));
g_signal_emit (manager, signals[USER_ADDED], 0, user);
g_object_unref (user);
@@ -291,11 +291,11 @@ um_user_manager_init (UmUserManager *manager)
manager->user_by_object_path = g_hash_table_new_full (g_str_hash,
g_str_equal,
- NULL,
+ g_free,
g_object_unref);
manager->user_by_name = g_hash_table_new_full (g_str_hash,
g_str_equal,
- NULL,
+ g_free,
g_object_unref);
manager->bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
@@ -601,7 +601,7 @@ UmUser *
um_user_manager_get_user_by_id (UmUserManager *manager,
uid_t uid)
{
- struct passwd *pwent;
+ struct passwd *pwent;
pwent = getpwuid (uid);
if (!pwent) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]