user-controls: Don’t clear filter if updating it is a no-op

If `self->user == NULL`, don’t clear the app filter, as that leaves us
in a worse-off position than before.

Rename the method to make it clearer that it queries the filter from the
user.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
This commit is contained in:
Philip Withnall 2020-02-06 12:01:50 +00:00
parent 3519ac2dc1
commit e3f923b294
1 changed files with 5 additions and 6 deletions

View File

@ -198,12 +198,10 @@ flush_update_blacklisted_apps (MctUserControls *self)
} }
static void static void
update_app_filter (MctUserControls *self) update_app_filter_from_user (MctUserControls *self)
{ {
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
g_clear_pointer (&self->filter, mct_app_filter_unref);
if (self->user == NULL) if (self->user == NULL)
return; return;
@ -217,6 +215,7 @@ update_app_filter (MctUserControls *self)
return; return;
/* FIXME: make it asynchronous */ /* FIXME: make it asynchronous */
g_clear_pointer (&self->filter, mct_app_filter_unref);
self->filter = mct_manager_get_app_filter (self->manager, self->filter = mct_manager_get_app_filter (self->manager,
act_user_get_uid (self->user), act_user_get_uid (self->user),
MCT_MANAGER_GET_VALUE_FLAGS_NONE, MCT_MANAGER_GET_VALUE_FLAGS_NONE,
@ -847,7 +846,7 @@ mct_user_controls_set_user (MctUserControls *self,
if (g_set_object (&self->user, user)) if (g_set_object (&self->user, user))
{ {
update_app_filter (self); update_app_filter_from_user (self);
setup_parental_control_settings (self); setup_parental_control_settings (self);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_USER]); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_USER]);
@ -861,7 +860,7 @@ on_permission_allowed_cb (GObject *obj,
{ {
MctUserControls *self = MCT_USER_CONTROLS (user_data); MctUserControls *self = MCT_USER_CONTROLS (user_data);
update_app_filter (self); update_app_filter_from_user (self);
setup_parental_control_settings (self); setup_parental_control_settings (self);
} }
@ -901,7 +900,7 @@ mct_user_controls_set_permission (MctUserControls *self,
} }
/* Handle changes. */ /* Handle changes. */
update_app_filter (self); update_app_filter_from_user (self);
setup_parental_control_settings (self); setup_parental_control_settings (self);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_PERMISSION]); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_PERMISSION]);