GNOME Bugzilla – Bug 791726
settings-widget: Fix connection button state out of sync after disconnect
Last modified: 2018-02-21 11:41:37 UTC
When disconnecting the switch showing the connected state could get out of sync. To fix this, use GtkSwitch feature to keep the state always in sync with the connected state and send the message to connect/disconnect when "active" is out of sync with "state".
Created attachment 365679 [details] [review] settings-widget: Fix connection button state out of sync after disconnect
Review of attachment 365679 [details] [review]: I don't think this was tested, so a reproducer would be appreciated. ::: lib/bluetooth-settings-widget.c @@ +1034,3 @@ +static gboolean +switch_connected_state_set (GtkSwitch *button, + gboolean *state, That's not the signature of that signal.
The signature for the "state-set" signal is: gboolean user_function (GtkSwitch *widget, gboolean state, gpointer user_data) Which is compatible with what the patch does. I am sure that I verified the patch, even if the test may have been "try toggling a lot".
(In reply to Bastien Nocera from comment #2) > + gboolean *state, this is a pointer (In reply to Benjamin Berg from comment #3) > gboolean state, this isn't
Ah, right! And that obviously still worked during testing because the calling convention puts the 32bit gboolean value into a 64bit register meaning that things worked fine …
Created attachment 368625 [details] [review] settings-widget: Fix connection button state out of sync after disconnect When disconnecting the switch showing the connected state could get out of sync. To fix this, use GtkSwitch feature to keep the state always in sync with the connected state and send the message to connect/disconnect when "active" is out of sync with "state". --- Main change is to fix the pointer. Patch still works as expected (even without the fix on x86_64 as the argument is always passed as 64bit in both cases).
Review of attachment 368625 [details] [review]: Looks good, thanks
Thanks for the review! Pushed to master. The following fix has been pushed: bc0b9fa settings-widget: Fix connection button state out of sync after disconnect
Created attachment 368704 [details] [review] settings-widget: Fix connection button state out of sync after disconnect When disconnecting the switch showing the connected state could get out of sync. To fix this, use GtkSwitch feature to keep the state always in sync with the connected state and send the message to connect/disconnect when "active" is out of sync with "state".