Merge lp:~3v1n0/unity/accelerators-controller-trigger-fix into lp:unity

Proposed by Marco Trevisan (Treviño) on 2016-07-26
Status: Merged
Approved by: Andrea Azzarone on 2016-07-26
Approved revision: 4155
Merged at revision: 4160
Proposed branch: lp:~3v1n0/unity/accelerators-controller-trigger-fix
Merge into: lp:unity
Prerequisite: lp:~azzar1/unity/fix-crash-acc-controller
Diff against target: 30 lines (+15/-5)
1 file modified
lockscreen/LockScreenAcceleratorController.cpp (+15/-5)
To merge this branch: bzr merge lp:~3v1n0/unity/accelerators-controller-trigger-fix
Reviewer Review Type Date Requested Status
Andrea Azzarone (community) 2016-07-26 Approve on 2016-07-26
Review via email: mp+301146@code.launchpad.net

Commit message

LockScreenAcceleratorController: ensure callbacks are valid before calling them

To post a comment you must log in.
Andrea Azzarone (azzar1) wrote :

-1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lockscreen/LockScreenAcceleratorController.cpp'
2--- lockscreen/LockScreenAcceleratorController.cpp 2016-07-26 09:23:27 +0000
3+++ lockscreen/LockScreenAcceleratorController.cpp 2016-07-26 09:23:27 +0000
4@@ -193,11 +193,21 @@
5
6 CompOption::Vector options;
7
8- if (action.initiate() && action.state() & CompAction::StateInitKey)
9- action.initiate()(&action, 0, options);
10-
11- if (action.terminate() && action.state() & CompAction::StateTermKey)
12- action.terminate()(&action, CompAction::StateTermTapped, options);
13+ if (action.state() & CompAction::StateInitKey)
14+ {
15+ auto const& initiate_cb = action.initiate();
16+
17+ if (!initiate_cb.empty())
18+ initiate_cb(&action, 0, options);
19+ }
20+
21+ if (action.state() & CompAction::StateTermKey)
22+ {
23+ auto const& terminate_cb = action.terminate();
24+
25+ if (!terminate_cb.empty())
26+ terminate_cb(&action, CompAction::StateTermTapped, options);
27+ }
28 }
29
30 Accelerators::Ptr const& AcceleratorController::GetAccelerators() const