From 64f2cdf9ed290a1fb7c2bf41753613078eb023c4 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Mon, 13 Dec 2021 12:53:32 +0200 Subject: [PATCH] Fix memory leak in some plasma components A few plasma components cache QSGTexture. Those components rely on texture references going away with QSGNode users. However, with the current tear down logic, OffscreenQuickView won't destroy any paint nodes. Destroy QQuickRenderControl before QQuickWindow to ensure that are no paint nodes left alive after OffscreenQuickView. BUG: 444429 BUG: 444381 BUG: 444077 BUG: 444306 --- src/libkwineffects/kwinoffscreenquickview.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/libkwineffects/kwinoffscreenquickview.cpp b/src/libkwineffects/kwinoffscreenquickview.cpp index bea0f3f0e1..733927e47a 100644 --- a/src/libkwineffects/kwinoffscreenquickview.cpp +++ b/src/libkwineffects/kwinoffscreenquickview.cpp @@ -176,12 +176,15 @@ OffscreenQuickView::OffscreenQuickView(QObject *parent, QWindow *renderWindow, E OffscreenQuickView::~OffscreenQuickView() { if (d->m_glcontext) { - d->m_glcontext->makeCurrent(d->m_offscreenSurface.data()); // close the view whilst we have an active GL context - delete d->m_view; - d->m_view = nullptr; - d->m_renderControl->invalidate(); + d->m_glcontext->makeCurrent(d->m_offscreenSurface.data()); } + + delete d->m_renderControl; // Always delete render control first. + d->m_renderControl = nullptr; + + delete d->m_view; + d->m_view = nullptr; } bool OffscreenQuickView::automaticRepaint() const