Merge lp:~3v1n0/unity/call-valid-action-callbacks into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Christopher Townsend
Approved revision: no longer in the source branch.
Merged at revision: 3799
Proposed branch: lp:~3v1n0/unity/call-valid-action-callbacks
Merge into: lp:unity
Diff against target: 37 lines (+9/-4)
1 file modified
unity-shared/PluginAdapter.cpp (+9/-4)
To merge this branch: bzr merge lp:~3v1n0/unity/call-valid-action-callbacks
Reviewer Review Type Date Requested Status
Christopher Townsend (community) Approve
Review via email: mp+217785@code.launchpad.net

Commit message

PluginAdapter: make sure we don't try to call an invalid initiate/terminate callback function

To post a comment you must log in.
Revision history for this message
Christopher Townsend (townsend) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'unity-shared/PluginAdapter.cpp'
2--- unity-shared/PluginAdapter.cpp 2014-04-02 21:42:12 +0000
3+++ unity-shared/PluginAdapter.cpp 2014-04-30 16:10:57 +0000
4@@ -248,7 +248,8 @@
5 argument.push_back(arg);
6
7 /* Initiate the selected action with the arguments */
8- action->initiate()(action, state, argument);
9+ if (CompAction::CallBack const& initiate_cb = primary_action_->initiate())
10+ initiate_cb(action, 0, argument);
11 }
12
13 void MultiActionList::InitiateAll(CompOption::Vector const& extra_args, int state) const
14@@ -291,8 +292,11 @@
15
16 if (primary_action_)
17 {
18- primary_action_->terminate()(primary_action_, CompAction::StateCancel, argument);
19- return;
20+ if (CompAction::CallBack const& terminate_cb = primary_action_->terminate())
21+ {
22+ terminate_cb(primary_action_, CompAction::StateCancel, argument);
23+ return;
24+ }
25 }
26
27 for (auto const& it : actions_)
28@@ -304,7 +308,8 @@
29 CompAction::StateTermEdge |
30 CompAction::StateTermEdgeDnd))
31 {
32- action->terminate()(action, 0, argument);
33+ if (CompAction::CallBack const& terminate_cb = primary_action_->terminate())
34+ terminate_cb(action, 0, argument);
35 }
36 }
37 }