Merge lp:~unity-api-team/indicator-network/lp1393488-14.09 into lp:indicator-network/14.09

Proposed by Antti Kaijanmäki
Status: Merged
Approved by: Jussi Pakkanen
Approved revision: 465
Merged at revision: 468
Proposed branch: lp:~unity-api-team/indicator-network/lp1393488-14.09
Merge into: lp:indicator-network/14.09
Diff against target: 81 lines (+22/-17)
3 files modified
src/indicator/quick-access-section.cpp (+17/-13)
src/menumodel-cpp/gio-helpers/util.cpp (+4/-3)
src/menumodel-cpp/gio-helpers/util.h (+1/-1)
To merge this branch: bzr merge lp:~unity-api-team/indicator-network/lp1393488-14.09
Reviewer Review Type Date Requested Status
Jussi Pakkanen (community) Approve
Review via email: mp+244148@code.launchpad.net

Commit message

fix flighmode switch bouncing on krillin.

To post a comment you must log in.
Revision history for this message
Jussi Pakkanen (jpakkane) wrote :

Yup.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/indicator/quick-access-section.cpp'
2--- src/indicator/quick-access-section.cpp 2014-10-29 18:12:05 +0000
3+++ src/indicator/quick-access-section.cpp 2014-12-09 14:49:14 +0000
4@@ -76,19 +76,23 @@
5 });
6 });
7 m_flightModeSwitch->activated().connect([this](){
8- if (m_flightModeSwitch->state().get()) {
9- try {
10- m_manager->enableFlightMode();
11- } catch (const std::exception &e) {
12- std::cerr << e.what() << std::endl;
13- }
14- } else {
15- try {
16- m_manager->disableFlightMode();
17- } catch (const std::exception &e) {
18- std::cerr << e.what() << std::endl;
19- }
20- }
21+ bool state = m_flightModeSwitch->state().get();
22+ auto manager = m_manager;
23+ GMainLoopDispatch([manager, state](){
24+ if (state) {
25+ try {
26+ manager->enableFlightMode();
27+ } catch (const std::exception &e) {
28+ std::cerr << e.what() << std::endl;
29+ }
30+ } else {
31+ try {
32+ manager->disableFlightMode();
33+ } catch (const std::exception &e) {
34+ std::cerr << e.what() << std::endl;
35+ }
36+ }
37+ }, G_PRIORITY_LOW, true);
38 });
39
40 m_actionGroupMerger->add(*m_flightModeSwitch);
41
42=== modified file 'src/menumodel-cpp/gio-helpers/util.cpp'
43--- src/menumodel-cpp/gio-helpers/util.cpp 2014-10-29 19:11:05 +0000
44+++ src/menumodel-cpp/gio-helpers/util.cpp 2014-12-09 14:49:14 +0000
45@@ -36,11 +36,12 @@
46 return G_SOURCE_REMOVE;
47 }
48
49-GMainLoopDispatch::GMainLoopDispatch(Func func)
50+GMainLoopDispatch::GMainLoopDispatch(Func func, int priority, bool force_delayed)
51 {
52 std::unique_lock<std::mutex> lock(_lock);
53
54- if (g_main_context_acquire(g_main_context_default())) {
55+ if (!force_delayed &&
56+ g_main_context_acquire(g_main_context_default())) {
57 // already running inside GMainLoop..
58 // free the lock and dispatch immediately.
59 lock.unlock();
60@@ -49,7 +50,7 @@
61 } else {
62 std::function<void()> *funcPtr = new std::function<void()>(func);
63 if (_funcs.empty()) {
64- g_idle_add_full(G_PRIORITY_HIGH,
65+ g_idle_add_full(priority,
66 GSourceFunc(GMainLoopDispatch::dispatch_cb),
67 NULL,
68 NULL);
69
70=== modified file 'src/menumodel-cpp/gio-helpers/util.h'
71--- src/menumodel-cpp/gio-helpers/util.h 2014-10-31 13:50:05 +0000
72+++ src/menumodel-cpp/gio-helpers/util.h 2014-12-09 14:49:14 +0000
73@@ -77,7 +77,7 @@
74 static std::list<Func *> _funcs;
75
76 //GMainLoopDispatch() = delete;
77- GMainLoopDispatch(Func func);
78+ GMainLoopDispatch(Func func, int priority=G_PRIORITY_HIGH, bool force_delayed=false);
79 };
80
81 struct GObjectDeleter {

Subscribers

People subscribed via source and target branches