After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 791727 - bluetooth-client: Remove all devices on adapter removal
bluetooth-client: Remove all devices on adapter removal
Status: RESOLVED FIXED
Product: gnome-bluetooth
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gnome-bluetooth-general-maint@gnome.bugs
gnome-bluetooth-general-maint@gnome.bugs
Depends on:
Blocks:
 
 
Reported: 2017-12-18 10:19 UTC by Benjamin Berg
Modified: 2018-02-20 11:43 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
bluetooth-client: Remove all devices on adapter removal (2.26 KB, patch)
2017-12-18 10:19 UTC, Benjamin Berg
needs-work Details | Review

Description Benjamin Berg 2017-12-18 10:19:20 UTC
Fixes a corner case when bluetoothd crashes.
Comment 1 Benjamin Berg 2017-12-18 10:19:24 UTC
Created attachment 365680 [details] [review]
bluetooth-client: Remove all devices on adapter removal

If bluetoothd fails badly (e.g. kill -9), then the devices may not be
removed before the adapter is removed. So clean up any left over device
at adapter removal as otherwise the "device-removed" is not fired.

Without this one ends up with stale entries in the bluetooth settings
widget after killing bluetoothd.
Comment 2 Bastien Nocera 2018-02-16 10:39:38 UTC
Review of attachment 365680 [details] [review]:

> Remove all devices on adapter removal

Please put the user-facing effect of the fix here (the description you have in the bug), rather than what the code is doing (which you already explain in the commit message).

Looks good after those changes.

::: lib/bluetooth-client.c
@@ +650,3 @@
 
+	/* Ensure that all devices are removed. This can happen if bluetoothd
+	 * crashes and does not unregister the objects. */

> and does not unregister the objects.

I'd rather:
"and ObjectManager doesn't send "object-removed" signals for children."

@@ +655,3 @@
+		GDBusProxy *object;
+
+		gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &childiter,

Space before "("

@@ +660,3 @@
+		g_signal_emit (G_OBJECT (client), signals[DEVICE_REMOVED], 0, g_dbus_proxy_get_object_path (object));
+		have_child = gtk_tree_store_remove (priv->store, &childiter);
+		g_object_unref (object);

unref() the object one line above, after its last use, and a linefeed before have_child =...
Comment 3 Benjamin Berg 2018-02-20 11:43:57 UTC
Pushed to master and gnome-3-26 with a more elaborate explanation.