diff options
| author | Marco Trevisan (TreviƱo) <mail@3v1n0.net> | 2016-07-27 10:24:03 +0000 |
|---|---|---|
| committer | Bileto Bot <ci-train-bot@canonical.com> | 2016-07-27 10:24:03 +0000 |
| commit | 4fd4d92a761c6e82ce8757a68b1baae03fe30755 (patch) | |
| tree | ce955cfdf02531ed0f78e1a7cfa73859f8172374 | |
| parent | daa27bd84611599ce8c5b876d01ea0c98b199357 (diff) | |
| parent | 0aa9ee17502aea82f132e1792e8d552e849149aa (diff) | |
LockScreenAcceleratorController: ensure callbacks are valid before calling them (LP: #1605012)
Approved by: Andrea Azzarone (bzr r4160)
| -rw-r--r-- | lockscreen/LockScreenAcceleratorController.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/lockscreen/LockScreenAcceleratorController.cpp b/lockscreen/LockScreenAcceleratorController.cpp index 26c3495ce..49dbd3bf1 100644 --- a/lockscreen/LockScreenAcceleratorController.cpp +++ b/lockscreen/LockScreenAcceleratorController.cpp @@ -193,11 +193,21 @@ void AcceleratorController::OnActionActivated(CompAction& action) CompOption::Vector options; - if (action.initiate() && action.state() & CompAction::StateInitKey) - action.initiate()(&action, 0, options); + if (action.state() & CompAction::StateInitKey) + { + auto const& initiate_cb = action.initiate(); + + if (!initiate_cb.empty()) + initiate_cb(&action, 0, options); + } - if (action.terminate() && action.state() & CompAction::StateTermKey) - action.terminate()(&action, CompAction::StateTermTapped, options); + if (action.state() & CompAction::StateTermKey) + { + auto const& terminate_cb = action.terminate(); + + if (!terminate_cb.empty()) + terminate_cb(&action, CompAction::StateTermTapped, options); + } } Accelerators::Ptr const& AcceleratorController::GetAccelerators() const |
