privacy: Make Bolt page visibility check cancellable

When the Bolt page gets disposed before it finishes initializing
its client object we get a crash. See #2700

A way to trigger the crash is to switch panels fast enough so that
the sync dbus call is not finished by the time the panel is disposed.

This is not a guaranteed fix since I can't reproduce the issue
consistently.
This commit is contained in:
Felipe Borges 2023-10-17 14:40:36 +02:00
parent c3bcaa4559
commit 0263993642

View file

@ -156,7 +156,7 @@ update_visibility (BoltClient *client,
if (client)
{
devices = bolt_client_list_devices (client, NULL, NULL);
devices = bolt_client_list_devices (client, self->cancellable, NULL);
if (devices)
visible = devices->len > 0;
}
@ -998,7 +998,8 @@ cc_bolt_page_init (CcBoltPage *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
bolt_client_new_async (NULL, on_visibility_client_ready, self);
self->cancellable = g_cancellable_new ();
bolt_client_new_async (self->cancellable, on_visibility_client_ready, g_object_ref (self));
gtk_stack_set_visible_child_name (self->container, "loading");
@ -1016,8 +1017,6 @@ cc_bolt_page_init (CcBoltPage *self)
self->device_dialog = cc_bolt_device_dialog_new ();
self->cancellable = g_cancellable_new ();
bolt_client_new_async (self->cancellable, bolt_client_ready, g_object_ref (self));
}