Merge lp:~azzar1/unity/lp-1217560 into lp:unity

Proposed by Andrea Azzarone
Status: Merged
Approved by: Francis Ginther
Approved revision: no longer in the source branch.
Merged at revision: 3513
Proposed branch: lp:~azzar1/unity/lp-1217560
Merge into: lp:unity
Diff against target: 102 lines (+41/-4)
3 files modified
launcher/EdgeBarrierController.cpp (+14/-3)
launcher/EdgeBarrierControllerPrivate.h (+3/-1)
tests/test_edge_barrier_controller.cpp (+24/-0)
To merge this branch: bzr merge lp:~azzar1/unity/lp-1217560
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Marco Trevisan (Treviño) Approve
Review via email: mp+185994@code.launchpad.net

Commit message

Derive EdgeBarrierController::Impl from sigc::trackable and remove the use of c++11 lambdas for callbacks.

Description of the change

== Problem ==
compiz crashed with SIGSEGV in std::function<bool>()

== Fix ==
Derive EdgeBarrierController::Impl from sigc::trackable and remove the use of c++11 lambdas for callbacks.

== Test ==
Unit tests addeded.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Using an unity::connection::Wrapper was ok as well, but this is fair enough.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/EdgeBarrierController.cpp'
2--- launcher/EdgeBarrierController.cpp 2013-08-09 16:14:45 +0000
3+++ launcher/EdgeBarrierController.cpp 2013-09-17 09:57:39 +0000
4@@ -86,10 +86,12 @@
5 auto monitors = uscreen->GetMonitors();
6 ResizeBarrierList(monitors);
7
8- uscreen->changed.connect([&](int primary, std::vector<nux::Geometry>& layout) {
9+ /* FIXME: Back to c++11 lambda once we get sigc::track_obj.
10+ uscreen->changed.connect(sigc::track_obj(([&](int primary, std::vector<nux::Geometry>& layout) {
11 ResizeBarrierList(layout);
12 SetupBarriers(layout);
13- });
14+ }));*/
15+ uscreen->changed.connect(sigc::mem_fun(this, &EdgeBarrierController::Impl::OnUScreenChanged));
16
17 parent_->sticky_edges.SetGetterFunction([this] {
18 return parent_->options() ? parent_->options()->edge_resist() : false;
19@@ -105,9 +107,12 @@
20 });
21
22 parent_->options.changed.connect([&](launcher::Options::Ptr options) {
23+ /* FIXME: Back to c++11 lambda once we get sigc::track_obj.
24 options->option_changed.connect([&]() {
25 SetupBarriers(UScreen::GetDefault()->GetMonitors());
26- });
27+ });*/
28+ options->option_changed.connect(sigc::bind<1>(sigc::mem_fun(this, &EdgeBarrierController::Impl::SetupBarriers),
29+ UScreen::GetDefault()->GetMonitors()));
30 SetupBarriers(UScreen::GetDefault()->GetMonitors());
31 });
32
33@@ -119,6 +124,12 @@
34 nux::GetGraphicsDisplay()->RemoveEventFilter(this);
35 }
36
37+void EdgeBarrierController::Impl::OnUScreenChanged(int primary, std::vector<nux::Geometry>& layout)
38+{
39+ ResizeBarrierList(layout);
40+ SetupBarriers(layout);
41+}
42+
43 void EdgeBarrierController::Impl::AddSubscriber(EdgeBarrierSubscriber* subscriber, unsigned int monitor, std::vector<EdgeBarrierSubscriber*>& subscribers)
44 {
45 if (monitor >= subscribers.size())
46
47=== modified file 'launcher/EdgeBarrierControllerPrivate.h'
48--- launcher/EdgeBarrierControllerPrivate.h 2013-08-09 16:14:45 +0000
49+++ launcher/EdgeBarrierControllerPrivate.h 2013-09-17 09:57:39 +0000
50@@ -30,7 +30,7 @@
51 {
52
53 // NOTE: This private header is not part of the public interface
54-struct EdgeBarrierController::Impl
55+struct EdgeBarrierController::Impl : public sigc::trackable
56 {
57 Impl(EdgeBarrierController *parent);
58 ~Impl();
59@@ -41,6 +41,8 @@
60 void ResizeBarrierList(std::vector<nux::Geometry> const& layout);
61 void SetupBarriers(std::vector<nux::Geometry> const& layout);
62
63+ void OnUScreenChanged(int primary, std::vector<nux::Geometry>& layout);
64+
65 void OnPointerBarrierEvent(PointerBarrierWrapper* owner, BarrierEvent::Ptr const& event);
66 void BarrierPush(PointerBarrierWrapper* owner, BarrierEvent::Ptr const& event);
67 void BarrierRelease(PointerBarrierWrapper* owner, int event);
68
69=== modified file 'tests/test_edge_barrier_controller.cpp'
70--- tests/test_edge_barrier_controller.cpp 2013-08-07 18:50:10 +0000
71+++ tests/test_edge_barrier_controller.cpp 2013-09-17 09:57:39 +0000
72@@ -126,6 +126,30 @@
73 }
74 }
75
76+TEST_F(TestEdgeBarrierController, UscreenChangedSignalDisconnection)
77+{
78+ {
79+ EdgeBarrierController bc;
80+ bc.options = std::make_shared<launcher::Options>();
81+ }
82+
83+ // Make sure it does not crash.
84+ uscreen.changed.emit(uscreen.GetPrimaryMonitor(), uscreen.GetMonitors());
85+}
86+
87+TEST_F(TestEdgeBarrierController, LauncherOptionChangedSignalDisconnection)
88+{
89+ auto options = std::make_shared<launcher::Options>();
90+
91+ {
92+ EdgeBarrierController bc;
93+ bc.options = options;
94+ }
95+
96+ // Make sure it does not crash.
97+ options->option_changed.emit();
98+}
99+
100 TEST_F(TestEdgeBarrierController, RemoveVerticalSubscriber)
101 {
102 for (unsigned i = 0; i < monitors::MAX; ++i)