File gnome-control-center-fix-users-crash.patch of Package gnome-control-center.9274

diff -urp gnome-control-center-3.26.2.orig/panels/user-accounts/um-carousel.c gnome-control-center-3.26.2/panels/user-accounts/um-carousel.c
--- gnome-control-center-3.26.2.orig/panels/user-accounts/um-carousel.c	2017-05-10 03:10:21.000000000 -0500
+++ gnome-control-center-3.26.2/panels/user-accounts/um-carousel.c	2018-04-26 11:48:31.084939061 -0500
@@ -202,6 +202,15 @@ um_carousel_select_item (UmCarousel
         gchar *page_name;
         gboolean page_changed = TRUE;
 
+        /* Select first user if none is specified */
+        if (item == NULL)
+        {
+                if (self->children != NULL)
+                        item = self->children->data;
+                else
+                        return;
+        }
+
         if (self->selected_item != NULL)
         {
                 page_changed = (self->selected_item->page != item->page);
@@ -304,10 +313,6 @@ um_carousel_add (GtkContainer *container
         gtk_widget_show_all (self->last_box);
 
         update_buttons_visibility (self);
-
-        /* If there's only one child, select it. */
-        if (self->children->next == NULL)
-                um_carousel_select_item_at_index (self, 0);
 }
 
 void
@@ -398,3 +403,9 @@ um_carousel_init (UmCarousel *self)
         g_signal_connect_swapped (self->stack, "size-allocate", G_CALLBACK (on_size_allocate), self);
         g_signal_connect_swapped (self->stack, "notify::transition-running", G_CALLBACK (on_transition_running), self);
 }
+
+guint
+um_carousel_get_item_count (UmCarousel *self)
+{
+        return g_list_length (self->children);
+}
diff -urp gnome-control-center-3.26.2.orig/panels/user-accounts/um-carousel.h gnome-control-center-3.26.2/panels/user-accounts/um-carousel.h
--- gnome-control-center-3.26.2.orig/panels/user-accounts/um-carousel.h	2017-05-10 03:10:21.000000000 -0500
+++ gnome-control-center-3.26.2/panels/user-accounts/um-carousel.h	2018-04-26 11:48:31.084939061 -0500
@@ -46,6 +46,8 @@ UmCarouselItem  *um_carousel_find_item
 void             um_carousel_select_item (UmCarousel     *self,
                                           UmCarouselItem *item);
 
+guint            um_carousel_get_item_count (UmCarousel  *self);
+
 G_END_DECLS
 
 #endif /* UM_CAROUSEL_H */
diff -urp gnome-control-center-3.26.2.orig/panels/user-accounts/um-user-panel.c gnome-control-center-3.26.2/panels/user-accounts/um-user-panel.c
--- gnome-control-center-3.26.2.orig/panels/user-accounts/um-user-panel.c	2018-04-26 11:48:17.396869696 -0500
+++ gnome-control-center-3.26.2/panels/user-accounts/um-user-panel.c	2018-04-26 11:48:31.084939061 -0500
@@ -239,6 +239,8 @@ user_added (ActUserManager *um, ActUser
         /* Show heading for other accounts if new one have been added. */
         show_carousel = (d->other_accounts > 0);
         gtk_revealer_set_reveal_child (GTK_REVEALER (d->carousel), show_carousel);
+
+        gtk_stack_set_visible_child_name (GTK_STACK (d->stack), PAGE_USERS);
 }
 
 static gint
@@ -276,7 +278,7 @@ reload_users (CcUserPanelPrivate *d, Act
 {
         ActUser *user;
         GSList *list, *l;
-        UmCarouselItem *item;
+        UmCarouselItem *item = NULL;
         GtkSettings *settings;
         gboolean animations;
         gboolean can_reload;
@@ -288,8 +290,6 @@ reload_users (CcUserPanelPrivate *d, Act
 
         um_carousel_purge_items (d->carousel);
 
-        d->other_accounts = 0;
-
         list = act_user_manager_list_users (d->um);
         g_debug ("Got %d users\n", g_slist_length (list));
 
@@ -308,31 +308,18 @@ reload_users (CcUserPanelPrivate *d, Act
         }
         g_slist_free (list);
 
-        if (selected_user) {
+        if (um_carousel_get_item_count (d->carousel) == 0)
+                gtk_stack_set_visible_child_name (GTK_STACK (d->stack), PAGE_NO_USERS);
+        if (d->other_accounts == 0)
+                gtk_revealer_set_reveal_child (GTK_REVEALER (d->carousel), FALSE);
+
+        if (selected_user)
                 item = um_carousel_find_item (d->carousel, selected_user, user_compare);
-                um_carousel_select_item (d->carousel, item);
-        }
+        um_carousel_select_item (d->carousel, item);
 
         g_object_set (settings, "gtk-enable-animations", animations, NULL);
 }
 
-static void
-user_removed (ActUserManager *um, ActUser *user, CcUserPanelPrivate *d)
-{
-        gboolean show_carousel;
-
-        d->other_accounts--;
-        show_carousel = (d->other_accounts > 0);
-        gtk_revealer_set_reveal_child (GTK_REVEALER (d->carousel),
-                                       show_carousel);
-
-        reload_users (d, NULL);
-
-        /* Show the current user */
-        user = act_user_manager_get_user_by_id (d->um, getuid ());
-        show_user (user, d);
-}
-
 static gint
 user_compare (gconstpointer i,
               gconstpointer u)
@@ -356,10 +343,7 @@ user_compare (gconstpointer i,
 static void
 user_changed (ActUserManager *um, ActUser *user, CcUserPanelPrivate *d)
 {
-        if (act_user_get_uid (user) != act_user_get_uid (d->selected_user))
-                return;
-
-        reload_users (d, user);
+        reload_users (d, d->selected_user);
 }
 
 static void
@@ -1120,7 +1104,6 @@ users_loaded (ActUserManager     *manage
               GParamSpec         *pspec,
               CcUserPanelPrivate *d)
 {
-        ActUser *user;
         GtkWidget *dialog;
 
         if (act_user_manager_no_service (d->um)) {
@@ -1142,13 +1125,9 @@ users_loaded (ActUserManager     *manage
         g_signal_connect (d->um, "user-changed", G_CALLBACK (user_changed), d);
         g_signal_connect (d->um, "user-is-logged-in-changed", G_CALLBACK (user_changed), d);
         g_signal_connect (d->um, "user-added", G_CALLBACK (user_added), d);
-        g_signal_connect (d->um, "user-removed", G_CALLBACK (user_removed), d);
+        g_signal_connect (d->um, "user-removed", G_CALLBACK (user_changed), d);
 
         reload_users (d, NULL);
-
-        /* Show the current user firstly. */
-        user = act_user_manager_get_user_by_id (d->um, getuid ());
-        show_user (user, d);
 }
 
 static void
openSUSE Build Service is sponsored by