From e3f923b2947671c9f38e348849e68598ebbc260e Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 6 Feb 2020 12:01:50 +0000 Subject: [PATCH] =?UTF-8?q?user-controls:=20Don=E2=80=99t=20clear=20filter?= =?UTF-8?q?=20if=20updating=20it=20is=20a=20no-op?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- libmalcontent-ui/user-controls.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/libmalcontent-ui/user-controls.c b/libmalcontent-ui/user-controls.c index 07d3c0c..151d73e 100644 --- a/libmalcontent-ui/user-controls.c +++ b/libmalcontent-ui/user-controls.c @@ -198,12 +198,10 @@ flush_update_blacklisted_apps (MctUserControls *self) } static void -update_app_filter (MctUserControls *self) +update_app_filter_from_user (MctUserControls *self) { g_autoptr(GError) error = NULL; - g_clear_pointer (&self->filter, mct_app_filter_unref); - if (self->user == NULL) return; @@ -217,6 +215,7 @@ update_app_filter (MctUserControls *self) return; /* FIXME: make it asynchronous */ + g_clear_pointer (&self->filter, mct_app_filter_unref); self->filter = mct_manager_get_app_filter (self->manager, act_user_get_uid (self->user), MCT_MANAGER_GET_VALUE_FLAGS_NONE, @@ -847,7 +846,7 @@ mct_user_controls_set_user (MctUserControls *self, if (g_set_object (&self->user, user)) { - update_app_filter (self); + update_app_filter_from_user (self); setup_parental_control_settings (self); 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); - update_app_filter (self); + update_app_filter_from_user (self); setup_parental_control_settings (self); } @@ -901,7 +900,7 @@ mct_user_controls_set_permission (MctUserControls *self, } /* Handle changes. */ - update_app_filter (self); + update_app_filter_from_user (self); setup_parental_control_settings (self); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_PERMISSION]);