Merge lp:~tintou/wingpanel-indicator-bluetooth/no-disconnect into lp:~wingpanel-devs/wingpanel-indicator-bluetooth/trunk

Proposed by Corentin Noël
Status: Merged
Approved by: Danielle Foré
Approved revision: 76
Merged at revision: 76
Proposed branch: lp:~tintou/wingpanel-indicator-bluetooth/no-disconnect
Merge into: lp:~wingpanel-devs/wingpanel-indicator-bluetooth/trunk
Diff against target: 26 lines (+9/-7)
1 file modified
src/Services/Manager.vala (+9/-7)
To merge this branch: bzr merge lp:~tintou/wingpanel-indicator-bluetooth/no-disconnect
Reviewer Review Type Date Requested Status
WingPanel Devs Pending
Review via email: mp+316131@code.launchpad.net

Commit message

Don't disconnect if this is not required

Description of the change

Don't disconnect at startup

To post a comment you must log in.
Revision history for this message
Adam Bieńkowski (donadigo) wrote :

Perhaps put the check outside the thread function and do a "if (!state)"?

Revision history for this message
Corentin Noël (tintou) wrote :

if (!state) and if (state == false) are the same condition, it's just that the "state" name isn't obvious so I prefer to explicitly keep the == false

I actually need the device.disconnect (); to be done on a separate thread so that it doesn't block the UI

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Services/Manager.vala'
2--- src/Services/Manager.vala 2017-01-22 16:33:44 +0000
3+++ src/Services/Manager.vala 2017-02-01 15:57:24 +0000
4@@ -187,13 +187,15 @@
5
6 public void set_global_state (bool state) {
7 new Thread<void*> (null, () => {
8- lock (devices) {
9- foreach (var device in devices.values) {
10- if (device.connected) {
11- try {
12- device.disconnect ();
13- } catch (Error e) {
14- critical (e.message);
15+ if (state == false) {
16+ lock (devices) {
17+ foreach (var device in devices.values) {
18+ if (device.connected) {
19+ try {
20+ device.disconnect ();
21+ } catch (Error e) {
22+ critical (e.message);
23+ }
24 }
25 }
26 }

Subscribers

People subscribed via source and target branches

to all changes: