Merge lp:~unity-api-team/indicator-network/krillin-wifi into lp:indicator-network/14.10
- krillin-wifi
- Merge into trunk.14.10
Status: | Merged |
---|---|
Approved by: | Antti Kaijanmäki |
Approved revision: | 433 |
Merged at revision: | 435 |
Proposed branch: | lp:~unity-api-team/indicator-network/krillin-wifi |
Merge into: | lp:indicator-network/14.10 |
Diff against target: |
691 lines (+236/-87) 16 files modified
src/connectivity-cpp/dbus-cpp/services/urfkill.h (+3/-3) src/connectivity-cpp/include/connectivity/networking/manager.h (+5/-0) src/connectivity-cpp/src/platform/nmofono/kill-switch.cpp (+2/-0) src/connectivity-cpp/src/platform/nmofono/kill-switch.h (+1/-0) src/connectivity-cpp/src/platform/nmofono/manager.cpp (+89/-4) src/connectivity-cpp/src/platform/nmofono/manager.h (+6/-0) src/connectivity-cpp/src/platform/nmofono/wifi/link.cpp (+5/-2) src/indicator/quick-access-section.cpp (+13/-4) src/indicator/wifi-link-item.h (+0/-37) src/indicator/wifi-section.cpp (+53/-11) src/menumodel-cpp/action-group-exporter.h (+7/-5) src/menumodel-cpp/action.cpp (+3/-1) src/menumodel-cpp/gio-helpers/util.cpp (+7/-2) src/menumodel-cpp/gio-helpers/util.h (+3/-2) src/menumodel-cpp/menu-merger.h (+17/-9) src/menumodel-cpp/menu.h (+22/-7) |
To merge this branch: | bzr merge lp:~unity-api-team/indicator-network/krillin-wifi |
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Charles Kerr (community) | Approve | ||
Review via email: mp+235879@code.launchpad.net |
Commit message
Fix wifi toggle on krillin.
Description of the change
fix wifi toggle on krillin.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:429
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Charles Kerr (charlesk) wrote : | # |
Nice thread fixes. :)
There are a couple of warts here that I've talked with Antti about offline, but they don't block this Critical and can wait until the next MP.
Antti Kaijanmäki (kaijanmaki) wrote : | # |
just a simple timeout increase.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:433
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'src/connectivity-cpp/dbus-cpp/services/urfkill.h' | |||
2 | --- src/connectivity-cpp/dbus-cpp/services/urfkill.h 2014-08-19 19:55:15 +0000 | |||
3 | +++ src/connectivity-cpp/dbus-cpp/services/urfkill.h 2014-09-26 13:07:38 +0000 | |||
4 | @@ -162,7 +162,7 @@ | |||
5 | 162 | 162 | ||
6 | 163 | static std::chrono::milliseconds default_timeout() | 163 | static std::chrono::milliseconds default_timeout() |
7 | 164 | { | 164 | { |
9 | 165 | return std::chrono::seconds{5}; | 165 | return std::chrono::seconds{15}; |
10 | 166 | } | 166 | } |
11 | 167 | }; | 167 | }; |
12 | 168 | 168 | ||
13 | @@ -179,7 +179,7 @@ | |||
14 | 179 | 179 | ||
15 | 180 | static std::chrono::milliseconds default_timeout() | 180 | static std::chrono::milliseconds default_timeout() |
16 | 181 | { | 181 | { |
18 | 182 | return std::chrono::seconds{5}; | 182 | return std::chrono::seconds{15}; |
19 | 183 | } | 183 | } |
20 | 184 | }; | 184 | }; |
21 | 185 | 185 | ||
22 | @@ -196,7 +196,7 @@ | |||
23 | 196 | 196 | ||
24 | 197 | static std::chrono::milliseconds default_timeout() | 197 | static std::chrono::milliseconds default_timeout() |
25 | 198 | { | 198 | { |
27 | 199 | return std::chrono::seconds{1}; | 199 | return std::chrono::seconds{5}; |
28 | 200 | } | 200 | } |
29 | 201 | }; | 201 | }; |
30 | 202 | }; | 202 | }; |
31 | 203 | 203 | ||
32 | === modified file 'src/connectivity-cpp/include/connectivity/networking/manager.h' | |||
33 | --- src/connectivity-cpp/include/connectivity/networking/manager.h 2014-08-19 19:55:15 +0000 | |||
34 | +++ src/connectivity-cpp/include/connectivity/networking/manager.h 2014-09-26 13:07:38 +0000 | |||
35 | @@ -128,6 +128,11 @@ | |||
36 | 128 | */ | 128 | */ |
37 | 129 | virtual const core::Property<std::uint32_t>& characteristics() const = 0; | 129 | virtual const core::Property<std::uint32_t>& characteristics() const = 0; |
38 | 130 | 130 | ||
39 | 131 | virtual const core::Property<bool>& hasWifi() const = 0; | ||
40 | 132 | virtual const core::Property<bool>& wifiEnabled() const = 0; | ||
41 | 133 | virtual bool enableWifi() = 0; | ||
42 | 134 | virtual bool disableWifi() = 0; | ||
43 | 135 | |||
44 | 131 | protected: | 136 | protected: |
45 | 132 | /** | 137 | /** |
46 | 133 | * @brief The default constructor is protected. | 138 | * @brief The default constructor is protected. |
47 | 134 | 139 | ||
48 | === modified file 'src/connectivity-cpp/src/platform/nmofono/kill-switch.cpp' | |||
49 | --- src/connectivity-cpp/src/platform/nmofono/kill-switch.cpp 2014-08-19 19:55:15 +0000 | |||
50 | +++ src/connectivity-cpp/src/platform/nmofono/kill-switch.cpp 2014-09-26 13:07:38 +0000 | |||
51 | @@ -38,6 +38,8 @@ | |||
52 | 38 | { | 38 | { |
53 | 39 | switch(value) { | 39 | switch(value) { |
54 | 40 | case URfkill::Interface::Killswitch::State::not_available: | 40 | case URfkill::Interface::Killswitch::State::not_available: |
55 | 41 | state.set(KillSwitch::State::not_available); | ||
56 | 42 | break; | ||
57 | 41 | case URfkill::Interface::Killswitch::State::unblocked: | 43 | case URfkill::Interface::Killswitch::State::unblocked: |
58 | 42 | state.set(KillSwitch::State::unblocked); | 44 | state.set(KillSwitch::State::unblocked); |
59 | 43 | break; | 45 | break; |
60 | 44 | 46 | ||
61 | === modified file 'src/connectivity-cpp/src/platform/nmofono/kill-switch.h' | |||
62 | --- src/connectivity-cpp/src/platform/nmofono/kill-switch.h 2014-08-19 19:55:15 +0000 | |||
63 | +++ src/connectivity-cpp/src/platform/nmofono/kill-switch.h 2014-09-26 13:07:38 +0000 | |||
64 | @@ -61,6 +61,7 @@ | |||
65 | 61 | 61 | ||
66 | 62 | enum class State | 62 | enum class State |
67 | 63 | { | 63 | { |
68 | 64 | not_available, | ||
69 | 64 | unblocked, | 65 | unblocked, |
70 | 65 | soft_blocked, | 66 | soft_blocked, |
71 | 66 | hard_blocked | 67 | hard_blocked |
72 | 67 | 68 | ||
73 | === modified file 'src/connectivity-cpp/src/platform/nmofono/manager.cpp' | |||
74 | --- src/connectivity-cpp/src/platform/nmofono/manager.cpp 2014-08-28 12:13:29 +0000 | |||
75 | +++ src/connectivity-cpp/src/platform/nmofono/manager.cpp 2014-09-26 13:07:38 +0000 | |||
76 | @@ -55,6 +55,31 @@ | |||
77 | 55 | core::Property<connectivity::networking::Manager::NetworkingStatus> m_status; | 55 | core::Property<connectivity::networking::Manager::NetworkingStatus> m_status; |
78 | 56 | core::Property<std::uint32_t> m_characteristics; | 56 | core::Property<std::uint32_t> m_characteristics; |
79 | 57 | std::unique_ptr<State> m_state; | 57 | std::unique_ptr<State> m_state; |
80 | 58 | |||
81 | 59 | core::Property<bool> m_hasWifi; | ||
82 | 60 | core::Property<bool> m_wifiEnabled ; | ||
83 | 61 | std::shared_ptr<KillSwitch> m_wifiKillSwitch; | ||
84 | 62 | |||
85 | 63 | void updateHasWifi() | ||
86 | 64 | { | ||
87 | 65 | if (m_wifiKillSwitch->state().get() != KillSwitch::State::not_available) { | ||
88 | 66 | m_hasWifi.set(true); | ||
89 | 67 | if (m_wifiKillSwitch->state().get() == KillSwitch::State::unblocked) | ||
90 | 68 | m_wifiEnabled.set(true); | ||
91 | 69 | else | ||
92 | 70 | m_wifiEnabled.set(false); | ||
93 | 71 | return; | ||
94 | 72 | } | ||
95 | 73 | |||
96 | 74 | // ok, killswitch not supported, but we still might have wifi devices | ||
97 | 75 | bool haswifi = false; | ||
98 | 76 | for (auto link : m_links.get()) { | ||
99 | 77 | if (link->type() == networking::Link::Type::wifi) | ||
100 | 78 | haswifi = true; | ||
101 | 79 | } | ||
102 | 80 | m_hasWifi.set(haswifi); | ||
103 | 81 | m_wifiEnabled.set(haswifi); | ||
104 | 82 | } | ||
105 | 58 | }; | 83 | }; |
106 | 59 | } | 84 | } |
107 | 60 | } | 85 | } |
108 | @@ -143,6 +168,10 @@ | |||
109 | 143 | /// @todo offload the initialization to a thread or something | 168 | /// @todo offload the initialization to a thread or something |
110 | 144 | /// @todo those Id() thingies | 169 | /// @todo those Id() thingies |
111 | 145 | 170 | ||
112 | 171 | p->m_wifiKillSwitch = std::make_shared<KillSwitch>(p->urfkill, | ||
113 | 172 | p->urfkill->switches[fdo::URfkill::Interface::Killswitch::Type::wlan]); | ||
114 | 173 | p->m_wifiKillSwitch->state().changed().connect(std::bind(&Private::updateHasWifi, p.get())); | ||
115 | 174 | |||
116 | 146 | p->nm->device_added->connect([this](const dbus::types::ObjectPath &path){ | 175 | p->nm->device_added->connect([this](const dbus::types::ObjectPath &path){ |
117 | 147 | std::cout << "Device Added:" << path.as_string() << std::endl; | 176 | std::cout << "Device Added:" << path.as_string() << std::endl; |
118 | 148 | auto links = p->m_links.get(); | 177 | auto links = p->m_links.get(); |
119 | @@ -158,10 +187,11 @@ | |||
120 | 158 | if (dev.type() == NM::Interface::Device::Type::wifi) { | 187 | if (dev.type() == NM::Interface::Device::Type::wifi) { |
121 | 159 | links.insert(std::make_shared<wifi::Link>(dev, | 188 | links.insert(std::make_shared<wifi::Link>(dev, |
122 | 160 | *p->nm.get(), | 189 | *p->nm.get(), |
125 | 161 | std::make_shared<KillSwitch>(p->urfkill, | 190 | p->m_wifiKillSwitch)); |
124 | 162 | p->urfkill->switches[fdo::URfkill::Interface::Killswitch::Type::wlan]))); | ||
126 | 163 | p->m_links.set(links); | 191 | p->m_links.set(links); |
127 | 164 | } | 192 | } |
128 | 193 | |||
129 | 194 | p->updateHasWifi(); | ||
130 | 165 | }); | 195 | }); |
131 | 166 | p->nm->device_removed->connect([this](const dbus::types::ObjectPath &path){ | 196 | p->nm->device_removed->connect([this](const dbus::types::ObjectPath &path){ |
132 | 167 | std::cout << "Device Removed:" << path.as_string() << std::endl; | 197 | std::cout << "Device Removed:" << path.as_string() << std::endl; |
133 | @@ -173,6 +203,8 @@ | |||
134 | 173 | } | 203 | } |
135 | 174 | } | 204 | } |
136 | 175 | p->m_links.set(links); | 205 | p->m_links.set(links); |
137 | 206 | |||
138 | 207 | p->updateHasWifi(); | ||
139 | 176 | }); | 208 | }); |
140 | 177 | std::set<std::shared_ptr<networking::Link> > links; | 209 | std::set<std::shared_ptr<networking::Link> > links; |
141 | 178 | for(auto dev : p->nm->get_devices()) { | 210 | for(auto dev : p->nm->get_devices()) { |
142 | @@ -182,8 +214,7 @@ | |||
143 | 182 | std::shared_ptr<networking::Link> link; | 214 | std::shared_ptr<networking::Link> link; |
144 | 183 | link.reset(new wifi::Link(dev, | 215 | link.reset(new wifi::Link(dev, |
145 | 184 | *p->nm.get(), | 216 | *p->nm.get(), |
148 | 185 | std::make_shared<KillSwitch>(p->urfkill, | 217 | p->m_wifiKillSwitch)); |
147 | 186 | p->urfkill->switches[fdo::URfkill::Interface::Killswitch::Type::wlan]))); | ||
149 | 187 | links.insert(link); | 218 | links.insert(link); |
150 | 188 | break; | 219 | break; |
151 | 189 | } | 220 | } |
152 | @@ -219,6 +250,8 @@ | |||
153 | 219 | 250 | ||
154 | 220 | /// @todo set by the default connections. | 251 | /// @todo set by the default connections. |
155 | 221 | p->m_characteristics.set(networking::Link::Characteristics::empty); | 252 | p->m_characteristics.set(networking::Link::Characteristics::empty); |
156 | 253 | |||
157 | 254 | p->updateHasWifi(); | ||
158 | 222 | } | 255 | } |
159 | 223 | 256 | ||
160 | 224 | void | 257 | void |
161 | @@ -269,3 +302,55 @@ | |||
162 | 269 | { | 302 | { |
163 | 270 | return p->m_characteristics; | 303 | return p->m_characteristics; |
164 | 271 | } | 304 | } |
165 | 305 | |||
166 | 306 | const core::Property<bool>& | ||
167 | 307 | Manager::hasWifi() const | ||
168 | 308 | { | ||
169 | 309 | return p->m_hasWifi; | ||
170 | 310 | } | ||
171 | 311 | |||
172 | 312 | const core::Property<bool>& | ||
173 | 313 | Manager::wifiEnabled() const | ||
174 | 314 | { | ||
175 | 315 | return p->m_wifiEnabled; | ||
176 | 316 | } | ||
177 | 317 | |||
178 | 318 | |||
179 | 319 | bool | ||
180 | 320 | Manager::enableWifi() | ||
181 | 321 | { | ||
182 | 322 | if (!p->m_hasWifi.get()) | ||
183 | 323 | return false; | ||
184 | 324 | |||
185 | 325 | try { | ||
186 | 326 | if (p->m_wifiKillSwitch->state() == KillSwitch::State::soft_blocked) { | ||
187 | 327 | // try to unblock. throws if fails. | ||
188 | 328 | p->m_wifiKillSwitch->unblock(); | ||
189 | 329 | } | ||
190 | 330 | p->nm->wireless_enabled->set(true); | ||
191 | 331 | } catch(std::runtime_error &e) { | ||
192 | 332 | std::cerr << __PRETTY_FUNCTION__ << ": " << e.what() << std::endl; | ||
193 | 333 | return false; | ||
194 | 334 | } | ||
195 | 335 | return true; | ||
196 | 336 | } | ||
197 | 337 | |||
198 | 338 | bool | ||
199 | 339 | Manager::disableWifi() | ||
200 | 340 | { | ||
201 | 341 | if (!p->m_hasWifi.get()) | ||
202 | 342 | return false; | ||
203 | 343 | |||
204 | 344 | try { | ||
205 | 345 | if (p->m_wifiKillSwitch->state() == KillSwitch::State::unblocked) { | ||
206 | 346 | // block the device. that will disable it also | ||
207 | 347 | p->m_wifiKillSwitch->block(); | ||
208 | 348 | } | ||
209 | 349 | p->nm->wireless_enabled->set(false); | ||
210 | 350 | } catch(std::runtime_error &e) { | ||
211 | 351 | std::cerr << __PRETTY_FUNCTION__ << ": " << e.what() << std::endl; | ||
212 | 352 | return false; | ||
213 | 353 | } | ||
214 | 354 | return true; | ||
215 | 355 | } | ||
216 | 356 | |||
217 | 272 | 357 | ||
218 | === modified file 'src/connectivity-cpp/src/platform/nmofono/manager.h' | |||
219 | --- src/connectivity-cpp/src/platform/nmofono/manager.h 2014-08-19 19:55:15 +0000 | |||
220 | +++ src/connectivity-cpp/src/platform/nmofono/manager.h 2014-09-26 13:07:38 +0000 | |||
221 | @@ -51,6 +51,12 @@ | |||
222 | 51 | void disableFlightMode() override; | 51 | void disableFlightMode() override; |
223 | 52 | const core::Property<connectivity::networking::Manager::FlightModeStatus>& flightMode() const override; | 52 | const core::Property<connectivity::networking::Manager::FlightModeStatus>& flightMode() const override; |
224 | 53 | 53 | ||
225 | 54 | const core::Property<bool>& hasWifi() const override; | ||
226 | 55 | const core::Property<bool>& wifiEnabled() const override; | ||
227 | 56 | |||
228 | 57 | bool enableWifi() override; | ||
229 | 58 | bool disableWifi() override; | ||
230 | 59 | |||
231 | 54 | const core::Property<std::set<std::shared_ptr<connectivity::networking::Link>>>& links() const; | 60 | const core::Property<std::set<std::shared_ptr<connectivity::networking::Link>>>& links() const; |
232 | 55 | const core::Property<std::set<std::shared_ptr<connectivity::networking::Service>>>&services() const override; | 61 | const core::Property<std::set<std::shared_ptr<connectivity::networking::Service>>>&services() const override; |
233 | 56 | const core::Property<connectivity::networking::Manager::NetworkingStatus> & status() const override; | 62 | const core::Property<connectivity::networking::Manager::NetworkingStatus> & status() const override; |
234 | 57 | 63 | ||
235 | === modified file 'src/connectivity-cpp/src/platform/nmofono/wifi/link.cpp' | |||
236 | --- src/connectivity-cpp/src/platform/nmofono/wifi/link.cpp 2014-09-04 07:48:13 +0000 | |||
237 | +++ src/connectivity-cpp/src/platform/nmofono/wifi/link.cpp 2014-09-26 13:07:38 +0000 | |||
238 | @@ -100,6 +100,8 @@ | |||
239 | 100 | org::freedesktop::NetworkManager::Interface::NetworkManager nm; | 100 | org::freedesktop::NetworkManager::Interface::NetworkManager nm; |
240 | 101 | 101 | ||
241 | 102 | KillSwitch::Ptr killSwitch; | 102 | KillSwitch::Ptr killSwitch; |
242 | 103 | // hack hack | ||
243 | 104 | std::vector<core::ScopedConnection> switchConnection; | ||
244 | 103 | 105 | ||
245 | 104 | std::map<AccessPointKey, std::shared_ptr<GroupedAccessPoint>> grouper; | 106 | std::map<AccessPointKey, std::shared_ptr<GroupedAccessPoint>> grouper; |
246 | 105 | bool disabled; | 107 | bool disabled; |
247 | @@ -146,9 +148,9 @@ | |||
248 | 146 | // std::uint32_t reason = std::get<2>(args); | 148 | // std::uint32_t reason = std::get<2>(args); |
249 | 147 | updateDeviceState(new_state); | 149 | updateDeviceState(new_state); |
250 | 148 | }); | 150 | }); |
252 | 149 | p->killSwitch->state().changed().connect([this](platform::nmofono::KillSwitch::State){ | 151 | p->switchConnection.emplace_back(p->killSwitch->state().changed().connect([this](platform::nmofono::KillSwitch::State){ |
253 | 150 | updateDeviceState(p->lastState); | 152 | updateDeviceState(p->lastState); |
255 | 151 | }); | 153 | })); |
256 | 152 | } | 154 | } |
257 | 153 | 155 | ||
258 | 154 | Link::~Link() | 156 | Link::~Link() |
259 | @@ -428,6 +430,7 @@ | |||
260 | 428 | case KillSwitch::State::soft_blocked: | 430 | case KillSwitch::State::soft_blocked: |
261 | 429 | p->status_.set(Status::disabled); | 431 | p->status_.set(Status::disabled); |
262 | 430 | break; | 432 | break; |
263 | 433 | case KillSwitch::State::not_available: | ||
264 | 431 | case KillSwitch::State::unblocked: | 434 | case KillSwitch::State::unblocked: |
265 | 432 | p->status_.set(Status::offline); | 435 | p->status_.set(Status::offline); |
266 | 433 | } | 436 | } |
267 | 434 | 437 | ||
268 | === modified file 'src/indicator/quick-access-section.cpp' | |||
269 | --- src/indicator/quick-access-section.cpp 2014-05-27 16:06:14 +0000 | |||
270 | +++ src/indicator/quick-access-section.cpp 2014-09-26 13:07:38 +0000 | |||
271 | @@ -65,10 +65,19 @@ | |||
272 | 65 | } | 65 | } |
273 | 66 | }); | 66 | }); |
274 | 67 | m_flightModeSwitch->activated().connect([this](){ | 67 | m_flightModeSwitch->activated().connect([this](){ |
279 | 68 | if (m_flightModeSwitch->state().get()) | 68 | if (m_flightModeSwitch->state().get()) { |
280 | 69 | m_manager->enableFlightMode(); | 69 | try { |
281 | 70 | else | 70 | m_manager->enableFlightMode(); |
282 | 71 | m_manager->disableFlightMode(); | 71 | } catch (const std::exception &e) { |
283 | 72 | std::cout << e.what() << std::endl; | ||
284 | 73 | } | ||
285 | 74 | } else { | ||
286 | 75 | try { | ||
287 | 76 | m_manager->disableFlightMode(); | ||
288 | 77 | } catch (const std::exception &e) { | ||
289 | 78 | std::cout << e.what() << std::endl; | ||
290 | 79 | } | ||
291 | 80 | } | ||
292 | 72 | }); | 81 | }); |
293 | 73 | 82 | ||
294 | 74 | m_actionGroupMerger->add(*m_flightModeSwitch); | 83 | m_actionGroupMerger->add(*m_flightModeSwitch); |
295 | 75 | 84 | ||
296 | === modified file 'src/indicator/wifi-link-item.h' | |||
297 | --- src/indicator/wifi-link-item.h 2014-08-15 11:49:44 +0000 | |||
298 | +++ src/indicator/wifi-link-item.h 2014-09-26 13:07:38 +0000 | |||
299 | @@ -42,8 +42,6 @@ | |||
300 | 42 | /// @todo do something with me... | 42 | /// @todo do something with me... |
301 | 43 | Action::Ptr m_actionBusy; | 43 | Action::Ptr m_actionBusy; |
302 | 44 | 44 | ||
303 | 45 | SwitchItem::Ptr m_switch; | ||
304 | 46 | |||
305 | 47 | networking::wifi::AccessPoint::Ptr m_activeAccessPoint; | 45 | networking::wifi::AccessPoint::Ptr m_activeAccessPoint; |
306 | 48 | std::map<networking::wifi::AccessPoint::Ptr, AccessPointItem::Ptr> m_accessPoints; | 46 | std::map<networking::wifi::AccessPoint::Ptr, AccessPointItem::Ptr> m_accessPoints; |
307 | 49 | 47 | ||
308 | @@ -85,40 +83,6 @@ | |||
309 | 85 | 83 | ||
310 | 86 | m_rootMerger = std::make_shared<MenuMerger>(); | 84 | m_rootMerger = std::make_shared<MenuMerger>(); |
311 | 87 | 85 | ||
312 | 88 | m_switch = std::make_shared<SwitchItem>(_("Wi-Fi"), "wifi", "enable"); | ||
313 | 89 | m_actionGroupMerger->add(*m_switch); | ||
314 | 90 | switch (m_link->status().get()) { | ||
315 | 91 | case networking::Link::Status::disabled: | ||
316 | 92 | m_switch->state().set(false); | ||
317 | 93 | break; | ||
318 | 94 | case networking::Link::Status::offline: | ||
319 | 95 | case networking::Link::Status::connecting: | ||
320 | 96 | case networking::Link::Status::connected: | ||
321 | 97 | case networking::Link::Status::online: | ||
322 | 98 | m_switch->state().set(true); | ||
323 | 99 | break; | ||
324 | 100 | } | ||
325 | 101 | m_link->status().changed().connect([this](networking::Link::Status value){ | ||
326 | 102 | switch (value) { | ||
327 | 103 | case networking::Link::Status::disabled: | ||
328 | 104 | m_switch->state().set(false); | ||
329 | 105 | break; | ||
330 | 106 | case networking::Link::Status::offline: | ||
331 | 107 | case networking::Link::Status::connecting: | ||
332 | 108 | case networking::Link::Status::connected: | ||
333 | 109 | case networking::Link::Status::online: | ||
334 | 110 | m_switch->state().set(true); | ||
335 | 111 | break; | ||
336 | 112 | } | ||
337 | 113 | }); | ||
338 | 114 | m_switch->activated().connect([this](){ | ||
339 | 115 | if (m_switch->state().get()) { | ||
340 | 116 | m_link->enable(); | ||
341 | 117 | } else { | ||
342 | 118 | m_link->disable(); | ||
343 | 119 | } | ||
344 | 120 | }); | ||
345 | 121 | |||
346 | 122 | m_accessPointCompare = [](MenuItem::Ptr a, MenuItem::Ptr b){ | 86 | m_accessPointCompare = [](MenuItem::Ptr a, MenuItem::Ptr b){ |
347 | 123 | // order alphabetically by SSID | 87 | // order alphabetically by SSID |
348 | 124 | 88 | ||
349 | @@ -152,7 +116,6 @@ | |||
350 | 152 | m_otherNetwork = std::make_shared<TextItem>(_("Other network…"), "wifi", "othernetwork"); | 116 | m_otherNetwork = std::make_shared<TextItem>(_("Other network…"), "wifi", "othernetwork"); |
351 | 153 | //m_actionGroupMerger->add(*m_otherNetwork); | 117 | //m_actionGroupMerger->add(*m_otherNetwork); |
352 | 154 | 118 | ||
353 | 155 | m_topMenu->append(*m_switch); | ||
354 | 156 | m_rootMerger->append(m_topMenu); | 119 | m_rootMerger->append(m_topMenu); |
355 | 157 | 120 | ||
356 | 158 | m_apsMerger->append(m_connectedBeforeApsMenu); | 121 | m_apsMerger->append(m_connectedBeforeApsMenu); |
357 | 159 | 122 | ||
358 | === modified file 'src/indicator/wifi-section.cpp' | |||
359 | --- src/indicator/wifi-section.cpp 2014-05-12 11:36:59 +0000 | |||
360 | +++ src/indicator/wifi-section.cpp 2014-09-26 13:07:38 +0000 | |||
361 | @@ -32,6 +32,8 @@ | |||
362 | 32 | Menu::Ptr m_menu; | 32 | Menu::Ptr m_menu; |
363 | 33 | Menu::Ptr m_settingsMenu; | 33 | Menu::Ptr m_settingsMenu; |
364 | 34 | 34 | ||
365 | 35 | SwitchItem::Ptr m_switch; | ||
366 | 36 | |||
367 | 35 | WifiLinkItem::Ptr m_wifiLink; | 37 | WifiLinkItem::Ptr m_wifiLink; |
368 | 36 | TextItem::Ptr m_openWifiSettings; | 38 | TextItem::Ptr m_openWifiSettings; |
369 | 37 | 39 | ||
370 | @@ -44,19 +46,36 @@ | |||
371 | 44 | m_settingsMenu = std::make_shared<Menu>(); | 46 | m_settingsMenu = std::make_shared<Menu>(); |
372 | 45 | 47 | ||
373 | 46 | 48 | ||
385 | 47 | for (auto link : m_manager->links().get()) { | 49 | m_switch = std::make_shared<SwitchItem>(_("Wi-Fi"), "wifi", "enable"); |
386 | 48 | auto wifi_link = std::dynamic_pointer_cast<networking::wifi::Link>(link); | 50 | |
387 | 49 | m_wifiLink = std::make_shared<WifiLinkItem>(wifi_link); | 51 | /// @todo don't now really care about actully being able to detach the whole |
388 | 50 | 52 | /// wifi chipset. on touch devices we always have wifi. | |
389 | 51 | m_actionGroupMerger->add(*m_wifiLink); | 53 | if (m_manager->hasWifi().get()) { |
390 | 52 | m_menu->append(*m_wifiLink); | 54 | m_actionGroupMerger->add(*m_switch); |
391 | 53 | m_settingsMenu->append(*m_wifiLink); | 55 | m_menu->append(*m_switch); |
392 | 54 | 56 | m_settingsMenu->append(*m_switch); | |
382 | 55 | // just take the first one now. | ||
383 | 56 | /// @todo multiple links and links()->changed() | ||
384 | 57 | break; | ||
393 | 58 | } | 57 | } |
394 | 59 | 58 | ||
395 | 59 | m_switch->state().set(m_manager->wifiEnabled().get()); | ||
396 | 60 | m_manager->wifiEnabled().changed().connect([this](bool value) { | ||
397 | 61 | m_switch->state().set(value); | ||
398 | 62 | }); | ||
399 | 63 | m_switch->activated().connect([this](){ | ||
400 | 64 | if (m_switch->state().get()) { | ||
401 | 65 | if (!m_manager->enableWifi()) { | ||
402 | 66 | /// try to work around the switch getting out of state on unity8 side | ||
403 | 67 | m_switch->state().set(false); | ||
404 | 68 | } | ||
405 | 69 | } else { | ||
406 | 70 | if (!m_manager->disableWifi()) | ||
407 | 71 | m_switch->state().set(true); | ||
408 | 72 | } | ||
409 | 73 | }); | ||
410 | 74 | |||
411 | 75 | |||
412 | 76 | m_manager->links().changed().connect(std::bind(&Private::updateLinks, this)); | ||
413 | 77 | updateLinks(); | ||
414 | 78 | |||
415 | 60 | m_openWifiSettings = std::make_shared<TextItem>(_("Wi-Fi settings…"), "wifi", "settings"); | 79 | m_openWifiSettings = std::make_shared<TextItem>(_("Wi-Fi settings…"), "wifi", "settings"); |
416 | 61 | m_openWifiSettings->activated().connect([](){ | 80 | m_openWifiSettings->activated().connect([](){ |
417 | 62 | UrlDispatcher::send("settings:///system/wifi", [](std::string url, bool success){ | 81 | UrlDispatcher::send("settings:///system/wifi", [](std::string url, bool success){ |
418 | @@ -69,6 +88,29 @@ | |||
419 | 69 | m_menu->append(*m_openWifiSettings); | 88 | m_menu->append(*m_openWifiSettings); |
420 | 70 | } | 89 | } |
421 | 71 | 90 | ||
422 | 91 | void updateLinks() | ||
423 | 92 | { | ||
424 | 93 | // remove all and recreate. we have top 1 now anyway | ||
425 | 94 | if (m_wifiLink) { | ||
426 | 95 | m_actionGroupMerger->remove(*m_wifiLink); | ||
427 | 96 | m_menu->removeAll(*m_wifiLink); | ||
428 | 97 | m_settingsMenu->removeAll(*m_wifiLink); | ||
429 | 98 | m_wifiLink.reset(); | ||
430 | 99 | } | ||
431 | 100 | |||
432 | 101 | for (auto link : m_manager->links().get()) { | ||
433 | 102 | auto wifi_link = std::dynamic_pointer_cast<networking::wifi::Link>(link); | ||
434 | 103 | m_wifiLink = std::make_shared<WifiLinkItem>(wifi_link); | ||
435 | 104 | |||
436 | 105 | m_actionGroupMerger->add(*m_wifiLink); | ||
437 | 106 | m_menu->append(*m_wifiLink); | ||
438 | 107 | m_settingsMenu->append(*m_wifiLink); | ||
439 | 108 | |||
440 | 109 | // just take the first one | ||
441 | 110 | break; | ||
442 | 111 | } | ||
443 | 112 | } | ||
444 | 113 | |||
445 | 72 | public: | 114 | public: |
446 | 73 | }; | 115 | }; |
447 | 74 | 116 | ||
448 | 75 | 117 | ||
449 | === modified file 'src/menumodel-cpp/action-group-exporter.h' | |||
450 | --- src/menumodel-cpp/action-group-exporter.h 2014-08-14 23:23:06 +0000 | |||
451 | +++ src/menumodel-cpp/action-group-exporter.h 2014-09-26 13:07:38 +0000 | |||
452 | @@ -63,19 +63,21 @@ | |||
453 | 63 | return; | 63 | return; |
454 | 64 | } | 64 | } |
455 | 65 | 65 | ||
456 | 66 | |||
457 | 67 | auto group = m_gSimpleActionGroup; | ||
458 | 66 | GMainLoopDispatch([=](){ | 68 | GMainLoopDispatch([=](){ |
459 | 67 | for (auto action : actionGroup->actions()) { | 69 | for (auto action : actionGroup->actions()) { |
461 | 68 | g_action_map_add_action(G_ACTION_MAP(m_gSimpleActionGroup.get()), action->gaction().get()); | 70 | g_action_map_add_action(G_ACTION_MAP(group.get()), action->gaction().get()); |
462 | 69 | } | 71 | } |
463 | 70 | }); | 72 | }); |
465 | 71 | actionGroup->actionAdded().connect([this](Action::Ptr action){ | 73 | actionGroup->actionAdded().connect([=](Action::Ptr action){ |
466 | 72 | GMainLoopDispatch([=](){ | 74 | GMainLoopDispatch([=](){ |
468 | 73 | g_action_map_add_action(G_ACTION_MAP(m_gSimpleActionGroup.get()), action->gaction().get()); | 75 | g_action_map_add_action(G_ACTION_MAP(group.get()), action->gaction().get()); |
469 | 74 | }); | 76 | }); |
470 | 75 | }); | 77 | }); |
472 | 76 | actionGroup->actionRemoved().connect([this](Action::Ptr action){ | 78 | actionGroup->actionRemoved().connect([=](Action::Ptr action){ |
473 | 77 | GMainLoopDispatch([=](){ | 79 | GMainLoopDispatch([=](){ |
475 | 78 | g_action_map_remove_action(G_ACTION_MAP(m_gSimpleActionGroup.get()), | 80 | g_action_map_remove_action(G_ACTION_MAP(group.get()), |
476 | 79 | action->name().c_str()); | 81 | action->name().c_str()); |
477 | 80 | }); | 82 | }); |
478 | 81 | }); | 83 | }); |
479 | 82 | 84 | ||
480 | === modified file 'src/menumodel-cpp/action.cpp' | |||
481 | --- src/menumodel-cpp/action.cpp 2014-08-14 23:23:06 +0000 | |||
482 | +++ src/menumodel-cpp/action.cpp 2014-09-26 13:07:38 +0000 | |||
483 | @@ -85,6 +85,7 @@ | |||
484 | 85 | g_signal_handler_disconnect(m_gaction.get(), m_activateHandlerId); | 85 | g_signal_handler_disconnect(m_gaction.get(), m_activateHandlerId); |
485 | 86 | if (m_changeStateHandlerId) | 86 | if (m_changeStateHandlerId) |
486 | 87 | g_signal_handler_disconnect(m_gaction.get(), m_changeStateHandlerId); | 87 | g_signal_handler_disconnect(m_gaction.get(), m_changeStateHandlerId); |
487 | 88 | GMainLoopSync([]{}); | ||
488 | 88 | } | 89 | } |
489 | 89 | 90 | ||
490 | 90 | std::string | 91 | std::string |
491 | @@ -99,8 +100,9 @@ | |||
492 | 99 | { | 100 | { |
493 | 100 | std::lock_guard<std::recursive_mutex> lg(m_mutex); | 101 | std::lock_guard<std::recursive_mutex> lg(m_mutex); |
494 | 101 | m_state = value; | 102 | m_state = value; |
495 | 103 | auto action = m_gaction; | ||
496 | 102 | GMainLoopDispatch([=](){ | 104 | GMainLoopDispatch([=](){ |
498 | 103 | g_simple_action_set_state(G_SIMPLE_ACTION(m_gaction.get()), value); | 105 | g_simple_action_set_state(G_SIMPLE_ACTION(action.get()), value); |
499 | 104 | }); | 106 | }); |
500 | 105 | /// @todo state changes don't work properly. We probably need to make the | 107 | /// @todo state changes don't work properly. We probably need to make the |
501 | 106 | /// state a Property to be able to get signals on change. | 108 | /// state a Property to be able to get signals on change. |
502 | 107 | 109 | ||
503 | === modified file 'src/menumodel-cpp/gio-helpers/util.cpp' | |||
504 | --- src/menumodel-cpp/gio-helpers/util.cpp 2014-08-14 23:23:06 +0000 | |||
505 | +++ src/menumodel-cpp/gio-helpers/util.cpp 2014-09-26 13:07:38 +0000 | |||
506 | @@ -20,7 +20,7 @@ | |||
507 | 20 | #include "util.h" | 20 | #include "util.h" |
508 | 21 | 21 | ||
509 | 22 | std::mutex GMainLoopDispatch::_lock; | 22 | std::mutex GMainLoopDispatch::_lock; |
511 | 23 | std::vector<GMainLoopDispatch::Func *> GMainLoopDispatch::_funcs; | 23 | std::list<GMainLoopDispatch::Func *> GMainLoopDispatch::_funcs; |
512 | 24 | 24 | ||
513 | 25 | gboolean | 25 | gboolean |
514 | 26 | GMainLoopDispatch::dispatch_cb(gpointer) | 26 | GMainLoopDispatch::dispatch_cb(gpointer) |
515 | @@ -37,7 +37,12 @@ | |||
516 | 37 | GMainLoopDispatch::GMainLoopDispatch(std::function<void()> func) | 37 | GMainLoopDispatch::GMainLoopDispatch(std::function<void()> func) |
517 | 38 | { | 38 | { |
518 | 39 | if (g_main_context_acquire(g_main_context_default())) { | 39 | if (g_main_context_acquire(g_main_context_default())) { |
520 | 40 | func(); | 40 | if (_funcs.empty()) |
521 | 41 | func(); | ||
522 | 42 | else { | ||
523 | 43 | std::function<void()> *funcPtr = new std::function<void()>(func); | ||
524 | 44 | _funcs.push_back(funcPtr); | ||
525 | 45 | } | ||
526 | 41 | g_main_context_release(g_main_context_default()); | 46 | g_main_context_release(g_main_context_default()); |
527 | 42 | } else { | 47 | } else { |
528 | 43 | std::lock_guard<std::mutex> lock(_lock); | 48 | std::lock_guard<std::mutex> lock(_lock); |
529 | 44 | 49 | ||
530 | === modified file 'src/menumodel-cpp/gio-helpers/util.h' | |||
531 | --- src/menumodel-cpp/gio-helpers/util.h 2014-08-15 11:59:20 +0000 | |||
532 | +++ src/menumodel-cpp/gio-helpers/util.h 2014-09-26 13:07:38 +0000 | |||
533 | @@ -28,6 +28,7 @@ | |||
534 | 28 | #include <condition_variable> | 28 | #include <condition_variable> |
535 | 29 | #include <iostream> | 29 | #include <iostream> |
536 | 30 | #include <vector> | 30 | #include <vector> |
537 | 31 | #include <list> | ||
538 | 31 | 32 | ||
539 | 32 | struct GMainLoopSync | 33 | struct GMainLoopSync |
540 | 33 | { | 34 | { |
541 | @@ -72,8 +73,8 @@ | |||
542 | 72 | public: | 73 | public: |
543 | 73 | typedef std::function<void()> Func; | 74 | typedef std::function<void()> Func; |
544 | 74 | static std::mutex _lock; | 75 | static std::mutex _lock; |
547 | 75 | // vector keeps the order of the functions | 76 | // list keeps the order of the functions |
548 | 76 | static std::vector<Func *> _funcs; | 77 | static std::list<Func *> _funcs; |
549 | 77 | 78 | ||
550 | 78 | //GMainLoopDispatch() = delete; | 79 | //GMainLoopDispatch() = delete; |
551 | 79 | GMainLoopDispatch(std::function<void()> func); | 80 | GMainLoopDispatch(std::function<void()> func); |
552 | 80 | 81 | ||
553 | === modified file 'src/menumodel-cpp/menu-merger.h' | |||
554 | --- src/menumodel-cpp/menu-merger.h 2014-08-14 23:23:06 +0000 | |||
555 | +++ src/menumodel-cpp/menu-merger.h 2014-09-26 13:07:38 +0000 | |||
556 | @@ -56,15 +56,18 @@ | |||
557 | 56 | gint added) | 56 | gint added) |
558 | 57 | { | 57 | { |
559 | 58 | int offset = m_startPositions[model] + position; | 58 | int offset = m_startPositions[model] + position; |
560 | 59 | auto menu = m_gmenu; | ||
561 | 59 | 60 | ||
570 | 60 | for (int i = 0; i < removed; ++i) { | 61 | GMainLoopDispatch([=](){ |
571 | 61 | g_menu_remove(m_gmenu.get(), offset); | 62 | for (int i = 0; i < removed; ++i) { |
572 | 62 | } | 63 | g_menu_remove(menu.get(), offset); |
573 | 63 | for (int i = added-1; i >= 0; --i) { | 64 | } |
574 | 64 | auto item = g_menu_item_new_from_model(model, position + i); | 65 | for (int i = added-1; i >= 0; --i) { |
575 | 65 | g_menu_insert_item(m_gmenu.get(), offset, item); | 66 | auto item = g_menu_item_new_from_model(model, position + i); |
576 | 66 | g_object_unref(item); | 67 | g_menu_insert_item(menu.get(), offset, item); |
577 | 67 | } | 68 | g_object_unref(item); |
578 | 69 | } | ||
579 | 70 | }); | ||
580 | 68 | 71 | ||
581 | 69 | int delta = added - removed; | 72 | int delta = added - removed; |
582 | 70 | bool update = false; | 73 | bool update = false; |
583 | @@ -89,6 +92,12 @@ | |||
584 | 89 | m_gmenu = make_gmenu_ptr(); | 92 | m_gmenu = make_gmenu_ptr(); |
585 | 90 | } | 93 | } |
586 | 91 | 94 | ||
587 | 95 | ~MenuMerger() | ||
588 | 96 | { | ||
589 | 97 | clear(); | ||
590 | 98 | GMainLoopSync([]{}); | ||
591 | 99 | } | ||
592 | 100 | |||
593 | 92 | void append(MenuModel::Ptr menu) | 101 | void append(MenuModel::Ptr menu) |
594 | 93 | { | 102 | { |
595 | 94 | // calculate the start position for the items for the new menu | 103 | // calculate the start position for the items for the new menu |
596 | @@ -106,7 +115,6 @@ | |||
597 | 106 | 115 | ||
598 | 107 | // add all items | 116 | // add all items |
599 | 108 | itemsChanged(*menu, 0, 0, g_menu_model_get_n_items(*menu)); | 117 | itemsChanged(*menu, 0, 0, g_menu_model_get_n_items(*menu)); |
600 | 109 | |||
601 | 110 | m_handlerId[*menu] = g_signal_connect(menu->operator GMenuModel *(), | 118 | m_handlerId[*menu] = g_signal_connect(menu->operator GMenuModel *(), |
602 | 111 | "items-changed", | 119 | "items-changed", |
603 | 112 | G_CALLBACK(MenuMerger::items_changed_cb), | 120 | G_CALLBACK(MenuMerger::items_changed_cb), |
604 | 113 | 121 | ||
605 | === modified file 'src/menumodel-cpp/menu.h' | |||
606 | --- src/menumodel-cpp/menu.h 2014-08-14 23:23:06 +0000 | |||
607 | +++ src/menumodel-cpp/menu.h 2014-09-26 13:07:38 +0000 | |||
608 | @@ -51,14 +51,18 @@ | |||
609 | 51 | virtual ~Menu() | 51 | virtual ~Menu() |
610 | 52 | { | 52 | { |
611 | 53 | std::lock_guard<std::recursive_mutex> lg(m_mutex); | 53 | std::lock_guard<std::recursive_mutex> lg(m_mutex); |
612 | 54 | clear(); | ||
613 | 55 | GMainLoopSync([]{}); | ||
614 | 54 | } | 56 | } |
615 | 55 | 57 | ||
616 | 56 | void append(MenuItem::Ptr item) | 58 | void append(MenuItem::Ptr item) |
617 | 57 | { | 59 | { |
618 | 58 | std::lock_guard<std::recursive_mutex> lg(m_mutex); | 60 | std::lock_guard<std::recursive_mutex> lg(m_mutex); |
619 | 59 | m_items.push_back(item); | 61 | m_items.push_back(item); |
620 | 62 | // prevent this-> from being captured | ||
621 | 63 | auto menu = m_gmenu; | ||
622 | 60 | GMainLoopDispatch([=](){ | 64 | GMainLoopDispatch([=](){ |
624 | 61 | g_menu_append_item(m_gmenu.get(), item->gmenuitem()); | 65 | g_menu_append_item(menu.get(), item->gmenuitem()); |
625 | 62 | }); | 66 | }); |
626 | 63 | if (std::count(m_items.begin(), m_items.end(), item) == 1) { | 67 | if (std::count(m_items.begin(), m_items.end(), item) == 1) { |
627 | 64 | /// @todo disconenct | 68 | /// @todo disconenct |
628 | @@ -66,9 +70,11 @@ | |||
629 | 66 | int index = 0; | 70 | int index = 0; |
630 | 67 | for (auto iter = m_items.begin(); iter != m_items.end(); ++iter) { | 71 | for (auto iter = m_items.begin(); iter != m_items.end(); ++iter) { |
631 | 68 | if (*iter == item) { | 72 | if (*iter == item) { |
632 | 73 | // prevent this-> from being captured | ||
633 | 74 | auto menu = m_gmenu; | ||
634 | 69 | GMainLoopDispatch([=](){ | 75 | GMainLoopDispatch([=](){ |
637 | 70 | g_menu_remove(m_gmenu.get(), index); | 76 | g_menu_remove(menu.get(), index); |
638 | 71 | g_menu_insert_item(m_gmenu.get(), index, item->gmenuitem()); | 77 | g_menu_insert_item(menu.get(), index, item->gmenuitem()); |
639 | 72 | }); | 78 | }); |
640 | 73 | } | 79 | } |
641 | 74 | ++index; | 80 | ++index; |
642 | @@ -88,8 +94,11 @@ | |||
643 | 88 | ++index; | 94 | ++index; |
644 | 89 | ++iter; | 95 | ++iter; |
645 | 90 | } | 96 | } |
646 | 97 | |||
647 | 98 | // prevent this-> from being captured | ||
648 | 99 | auto menu = m_gmenu; | ||
649 | 91 | GMainLoopDispatch([=](){ | 100 | GMainLoopDispatch([=](){ |
651 | 92 | g_menu_insert_item(m_gmenu.get(), index, item->gmenuitem()); | 101 | g_menu_insert_item(menu.get(), index, item->gmenuitem()); |
652 | 93 | }); | 102 | }); |
653 | 94 | m_items.insert(position, item); | 103 | m_items.insert(position, item); |
654 | 95 | } | 104 | } |
655 | @@ -132,8 +141,10 @@ | |||
656 | 132 | if (iter == m_items.end()) | 141 | if (iter == m_items.end()) |
657 | 133 | return; | 142 | return; |
658 | 134 | 143 | ||
659 | 144 | // prevent this-> from being captured | ||
660 | 145 | auto menu = m_gmenu; | ||
661 | 135 | GMainLoopDispatch([=](){ | 146 | GMainLoopDispatch([=](){ |
663 | 136 | g_menu_remove(m_gmenu.get(), index); | 147 | g_menu_remove(menu.get(), index); |
664 | 137 | }); | 148 | }); |
665 | 138 | m_items.erase(item); | 149 | m_items.erase(item); |
666 | 139 | } | 150 | } |
667 | @@ -147,9 +158,11 @@ | |||
668 | 147 | // work reversed so that GMenu positions match tbe m_items positions | 158 | // work reversed so that GMenu positions match tbe m_items positions |
669 | 148 | int index = m_items.size()-1; | 159 | int index = m_items.size()-1; |
670 | 149 | for (auto iter = m_items.rbegin(); iter != m_items.rend(); ++iter) { | 160 | for (auto iter = m_items.rbegin(); iter != m_items.rend(); ++iter) { |
671 | 161 | // prevent this-> from being captured | ||
672 | 162 | auto menu = m_gmenu; | ||
673 | 150 | if (*iter == item) { | 163 | if (*iter == item) { |
674 | 151 | GMainLoopDispatch([=](){ | 164 | GMainLoopDispatch([=](){ |
676 | 152 | g_menu_remove(m_gmenu.get(), index); | 165 | g_menu_remove(menu.get(), index); |
677 | 153 | }); | 166 | }); |
678 | 154 | } | 167 | } |
679 | 155 | --index; | 168 | --index; |
680 | @@ -201,8 +214,10 @@ | |||
681 | 201 | void clear() | 214 | void clear() |
682 | 202 | { | 215 | { |
683 | 203 | std::lock_guard<std::recursive_mutex> lg(m_mutex); | 216 | std::lock_guard<std::recursive_mutex> lg(m_mutex); |
684 | 217 | // prevent this-> from being captured | ||
685 | 218 | auto menu = m_gmenu; | ||
686 | 204 | GMainLoopDispatch([=](){ | 219 | GMainLoopDispatch([=](){ |
688 | 205 | g_menu_remove_all(m_gmenu.get()); | 220 | g_menu_remove_all(menu.get()); |
689 | 206 | }); | 221 | }); |
690 | 207 | m_items.clear(); | 222 | m_items.clear(); |
691 | 208 | } | 223 | } |
LGTM