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
=== modified file 'unity-shared/InputMonitor.cpp'
--- unity-shared/InputMonitor.cpp 2016-09-06 17:37:50 +0000
+++ unity-shared/InputMonitor.cpp 2017-02-28 17:29:16 +0000
@@ -225,7 +225,8 @@
225225
226 void UpdateEventMonitor()226 void UpdateEventMonitor()
227 {227 {
228 auto* dpy = nux::GetGraphicsDisplay()->GetX11Display();228 auto* nux_dpy = nux::GetGraphicsDisplay();
229 auto* dpy = nux_dpy ? nux_dpy->GetX11Display() : gdk_x11_get_default_xdisplay();
229 Window root = DefaultRootWindow(dpy);230 Window root = DefaultRootWindow(dpy);
230231
231 unsigned char master_dev_bits[XIMaskLen(XI_LASTEVENT)] = { 0 };232 unsigned char master_dev_bits[XIMaskLen(XI_LASTEVENT)] = { 0 };
@@ -263,9 +264,9 @@
263264
264 if (!pointer_callbacks_.empty() || !key_callbacks_.empty() || !barrier_callbacks_.empty())265 if (!pointer_callbacks_.empty() || !key_callbacks_.empty() || !barrier_callbacks_.empty())
265 {266 {
266 if (!event_filter_set_)267 if (!event_filter_set_ && nux_dpy)
267 {268 {
268 nux::GetGraphicsDisplay()->AddEventFilter({[] (XEvent event, void* data) {269 nux_dpy->AddEventFilter({[] (XEvent event, void* data) {
269 return static_cast<Impl*>(data)->HandleEvent(event);270 return static_cast<Impl*>(data)->HandleEvent(event);
270 }, this});271 }, this});
271272
@@ -275,7 +276,9 @@
275 }276 }
276 else if (event_filter_set_)277 else if (event_filter_set_)
277 {278 {
278 nux::GetGraphicsDisplay()->RemoveEventFilter(this);279 if (nux_dpy)
280 nux_dpy->RemoveEventFilter(this);
281
279 event_filter_set_ = false;282 event_filter_set_ = false;
280 LOG_DEBUG(logger) << "Event filter disabled";283 LOG_DEBUG(logger) << "Event filter disabled";
281 }284 }
282285
=== modified file 'unity-shared/MenuManager.cpp'
--- unity-shared/MenuManager.cpp 2016-09-06 17:37:50 +0000
+++ unity-shared/MenuManager.cpp 2017-02-28 17:29:16 +0000
@@ -325,17 +325,12 @@
325325
326 bool RegisterTracker(std::string const& menubar, PositionTracker const& cb)326 bool RegisterTracker(std::string const& menubar, PositionTracker const& cb)
327 {327 {
328 auto it = position_trackers_.find(menubar);328 bool added = position_trackers_.insert({menubar, cb}).second;
329329
330 if (it != end(position_trackers_))330 if (added && active_menubar_ == menubar)
331 return false;
332
333 position_trackers_.insert({menubar, cb});
334
335 if (active_menubar_ == menubar)
336 UpdateActiveTracker();331 UpdateActiveTracker();
337332
338 return true;333 return added;
339 }334 }
340335
341 bool UnregisterTracker(std::string const& menubar, PositionTracker const& cb)336 bool UnregisterTracker(std::string const& menubar, PositionTracker const& cb)