From 96ce7bd2ad924ec50b937b532f335cfc2a2ee73b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 10 Jun 2016 16:15:56 +0200 Subject: [PATCH] Properly call Toplevel::setSurface for wl_surface_id X11 client message event Summary: For an X11 window through Xwayland KWin gets a client message with the Surface id. KWin has two code paths for handling that: * Wayland Surface is created after the X11 event * Wayland Surface is created before the X11 event In the first code path in WaylandServer KWin called Toplevel::setSurface, the other code path just updated the m_surface without calling into setSurface. This means the connects for the Surface were not set up, resulting in the worst case in accessing deleted memory after the Surface was destroyed. This change now ensures that setSurface is called from both code paths. That should fix the potential crash and could also be a fix to the problem that sometimes X windows seem to not be damaged correctly. Reviewers: #kwin, #plasma_on_wayland Subscribers: plasma-devel, kwin Tags: #plasma_on_wayland, #kwin Differential Revision: https://phabricator.kde.org/D1820 --- events.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/events.cpp b/events.cpp index 4a4438763b..4d3fe80831 100644 --- a/events.cpp +++ b/events.cpp @@ -1525,7 +1525,9 @@ void Toplevel::clientMessageEvent(xcb_client_message_event_t *e) if (e->type == atoms->wl_surface_id) { m_surfaceId = e->data.data32[0]; if (auto w = waylandServer()) { - m_surface = KWayland::Server::SurfaceInterface::get(m_surfaceId, w->xWaylandConnection()); + if (auto s = KWayland::Server::SurfaceInterface::get(m_surfaceId, w->xWaylandConnection())) { + setSurface(s); + } } emit surfaceIdChanged(m_surfaceId); }