From e2d5ec606a39e3122d5f2f729b8ab90e0523b286 Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Wed, 27 Nov 2019 20:45:04 +0100 Subject: [PATCH] Destroy dmabuf implementation on EGL backend going down Summary: We leak memory if we do not destroy the dmabuf implementation on EGL backend going down. Also this makes sure everything is cleaned up on shutdown. FIXED-IN: 5.17.4 BUG: 413637 Test Plan: Compiles, settings change and shutdown ok. Reviewers: #kwin, davidedmundson Reviewed By: #kwin, davidedmundson Subscribers: davidedmundson, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D25577 --- linux_dmabuf.h | 2 +- platformsupport/scenes/opengl/abstract_egl_backend.cpp | 8 ++++++-- platformsupport/scenes/opengl/abstract_egl_backend.h | 3 +++ platformsupport/scenes/opengl/egl_dmabuf.h | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/linux_dmabuf.h b/linux_dmabuf.h index 834a48e32d..abf1793465 100644 --- a/linux_dmabuf.h +++ b/linux_dmabuf.h @@ -60,7 +60,7 @@ public: using Flags = KWayland::Server::LinuxDmabufUnstableV1Interface::Flags; explicit LinuxDmabuf(); - ~LinuxDmabuf(); + ~LinuxDmabuf() override; KWayland::Server::LinuxDmabufUnstableV1Buffer *importBuffer(const QVector &planes, uint32_t format, diff --git a/platformsupport/scenes/opengl/abstract_egl_backend.cpp b/platformsupport/scenes/opengl/abstract_egl_backend.cpp index ad61a27846..a0fc219b39 100644 --- a/platformsupport/scenes/opengl/abstract_egl_backend.cpp +++ b/platformsupport/scenes/opengl/abstract_egl_backend.cpp @@ -66,7 +66,10 @@ AbstractEglBackend::AbstractEglBackend() connect(Compositor::self(), &Compositor::aboutToDestroy, this, &AbstractEglBackend::unbindWaylandDisplay); } -AbstractEglBackend::~AbstractEglBackend() = default; +AbstractEglBackend::~AbstractEglBackend() +{ + delete m_dmaBuf; +} void AbstractEglBackend::unbindWaylandDisplay() { @@ -171,7 +174,8 @@ void AbstractEglBackend::initWayland() } } - EglDmabuf::factory(this); + Q_ASSERT(!m_dmaBuf); + m_dmaBuf = EglDmabuf::factory(this); } void AbstractEglBackend::initClientExtensions() diff --git a/platformsupport/scenes/opengl/abstract_egl_backend.h b/platformsupport/scenes/opengl/abstract_egl_backend.h index 18232fd045..078c4e9e74 100644 --- a/platformsupport/scenes/opengl/abstract_egl_backend.h +++ b/platformsupport/scenes/opengl/abstract_egl_backend.h @@ -39,6 +39,8 @@ class BufferInterface; namespace KWin { +class EglDmabuf; + class KWIN_EXPORT AbstractEglBackend : public QObject, public OpenGLBackend { Q_OBJECT @@ -85,6 +87,7 @@ private: EGLContext m_context = EGL_NO_CONTEXT; EGLConfig m_config = nullptr; QList m_clientExtensions; + EglDmabuf *m_dmaBuf = nullptr; }; class KWIN_EXPORT AbstractEglTexture : public SceneOpenGLTexturePrivate diff --git a/platformsupport/scenes/opengl/egl_dmabuf.h b/platformsupport/scenes/opengl/egl_dmabuf.h index e01dc53269..a9244f7437 100644 --- a/platformsupport/scenes/opengl/egl_dmabuf.h +++ b/platformsupport/scenes/opengl/egl_dmabuf.h @@ -77,7 +77,7 @@ public: static EglDmabuf* factory(AbstractEglBackend *backend); explicit EglDmabuf(AbstractEglBackend *backend); - ~EglDmabuf(); + ~EglDmabuf() override; KWayland::Server::LinuxDmabufUnstableV1Buffer *importBuffer(const QVector &planes, uint32_t format,