Merge lp:~3v1n0/unity/input-monitor-dtor-fixes into lp:unity

Proposed by Marco Trevisan (Treviño) on 2017-02-28
Status: Merged
Approved by: Andrea Azzarone on 2017-02-28
Approved revision: 4222
Merged at revision: 4224
Proposed branch: lp:~3v1n0/unity/input-monitor-dtor-fixes
Merge into: lp:unity
Diff against target: 62 lines (+11/-13)
2 files modified
unity-shared/InputMonitor.cpp (+7/-4)
unity-shared/MenuManager.cpp (+4/-9)
To merge this branch: bzr merge lp:~3v1n0/unity/input-monitor-dtor-fixes
Reviewer Review Type Date Requested Status
Unity Team 2017-02-28 Pending
Review via email: mp+318515@code.launchpad.net

Commit message

InputMonitor: don't try to deference an invalid Nux display

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

+1

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'unity-shared/InputMonitor.cpp'
2--- unity-shared/InputMonitor.cpp 2016-09-06 17:37:50 +0000
3+++ unity-shared/InputMonitor.cpp 2017-02-28 17:29:16 +0000
4@@ -225,7 +225,8 @@
5
6 void UpdateEventMonitor()
7 {
8- auto* dpy = nux::GetGraphicsDisplay()->GetX11Display();
9+ auto* nux_dpy = nux::GetGraphicsDisplay();
10+ auto* dpy = nux_dpy ? nux_dpy->GetX11Display() : gdk_x11_get_default_xdisplay();
11 Window root = DefaultRootWindow(dpy);
12
13 unsigned char master_dev_bits[XIMaskLen(XI_LASTEVENT)] = { 0 };
14@@ -263,9 +264,9 @@
15
16 if (!pointer_callbacks_.empty() || !key_callbacks_.empty() || !barrier_callbacks_.empty())
17 {
18- if (!event_filter_set_)
19+ if (!event_filter_set_ && nux_dpy)
20 {
21- nux::GetGraphicsDisplay()->AddEventFilter({[] (XEvent event, void* data) {
22+ nux_dpy->AddEventFilter({[] (XEvent event, void* data) {
23 return static_cast<Impl*>(data)->HandleEvent(event);
24 }, this});
25
26@@ -275,7 +276,9 @@
27 }
28 else if (event_filter_set_)
29 {
30- nux::GetGraphicsDisplay()->RemoveEventFilter(this);
31+ if (nux_dpy)
32+ nux_dpy->RemoveEventFilter(this);
33+
34 event_filter_set_ = false;
35 LOG_DEBUG(logger) << "Event filter disabled";
36 }
37
38=== modified file 'unity-shared/MenuManager.cpp'
39--- unity-shared/MenuManager.cpp 2016-09-06 17:37:50 +0000
40+++ unity-shared/MenuManager.cpp 2017-02-28 17:29:16 +0000
41@@ -325,17 +325,12 @@
42
43 bool RegisterTracker(std::string const& menubar, PositionTracker const& cb)
44 {
45- auto it = position_trackers_.find(menubar);
46-
47- if (it != end(position_trackers_))
48- return false;
49-
50- position_trackers_.insert({menubar, cb});
51-
52- if (active_menubar_ == menubar)
53+ bool added = position_trackers_.insert({menubar, cb}).second;
54+
55+ if (added && active_menubar_ == menubar)
56 UpdateActiveTracker();
57
58- return true;
59+ return added;
60 }
61
62 bool UnregisterTracker(std::string const& menubar, PositionTracker const& cb)