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 791726 - settings-widget: Fix connection button state out of sync after disconnect
settings-widget: Fix connection button state out of sync after disconnect
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:18 UTC by Benjamin Berg
Modified: 2018-02-21 11:41 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
settings-widget: Fix connection button state out of sync after disconnect (3.63 KB, patch)
2017-12-18 10:18 UTC, Benjamin Berg
none Details | Review
settings-widget: Fix connection button state out of sync after disconnect (3.63 KB, patch)
2018-02-20 11:46 UTC, Benjamin Berg
committed Details | Review
settings-widget: Fix connection button state out of sync after disconnect (3.63 KB, patch)
2018-02-21 11:41 UTC, Benjamin Berg
committed Details | Review

Description Benjamin Berg 2017-12-18 10:18:46 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".
Comment 1 Benjamin Berg 2017-12-18 10:18:50 UTC
Created attachment 365679 [details] [review]
settings-widget: Fix connection button state out of sync after disconnect
Comment 2 Bastien Nocera 2018-02-16 10:46:40 UTC
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.
Comment 3 Benjamin Berg 2018-02-16 11:12:32 UTC
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".
Comment 4 Bastien Nocera 2018-02-16 11:15:07 UTC
(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
Comment 5 Benjamin Berg 2018-02-16 11:28:14 UTC
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 …
Comment 6 Benjamin Berg 2018-02-20 11:46:39 UTC
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).
Comment 7 Bastien Nocera 2018-02-21 11:00:02 UTC
Review of attachment 368625 [details] [review]:

Looks good, thanks
Comment 8 Benjamin Berg 2018-02-21 11:41:31 UTC
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
Comment 9 Benjamin Berg 2018-02-21 11:41:37 UTC
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".