[plasma/kwin] src/effect: effects/offscreenquickview: restore EGL context on update() failure paths

Vlad Zahorodnii <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 74120bdb1da81b11c3648d4f41e85caade2b4d68 by Vlad Zahorodnii, on behalf of zhang shoucheng.
Committed on 17/08/2026 at 07:31.
Pushed by vladz into branch 'master'.

effects/offscreenquickview: restore EGL context on update() failure paths

update() only restored the previously current EGL context on the success
path. When swapchain creation or buffer acquisition failed, doneCurrent()
left the thread without a current context, so the compositor kept
rendering the frame without one. Use a scope guard to restore the
previous context on every exit path.

M  +6    -3    src/effect/offscreenquickview.cpp

https://invent.kde.org/plasma/kwin/-/commit/74120bdb1da81b11c3648d4f41e85caade2b4d68

diff --git a/src/effect/offscreenquickview.cpp b/src/effect/offscreenquickview.cpp
index d8e55f02bd7..424d46d391c 100644
--- a/src/effect/offscreenquickview.cpp
+++ b/src/effect/offscreenquickview.cpp
@@ -36,6 +36,7 @@
 #include <QQuickRenderControl>
 #include <QQuickView>
 #include <QStyleHints>
+#include <QScopeGuard>
 
 #include <QOffscreenSurface>
 #include <QOpenGLContext>
@@ -296,6 +297,11 @@ void OffscreenQuickView::update(OutputFrame *frame)
 
     bool usingGl = d->m_glcontext != nullptr;
     EglContext *previousContext = EglContext::currentContext();
+    const auto restoreContext = qScopeGuard([previousContext]() {
+        if (previousContext) {
+            (void)previousContext->makeCurrent();
+        }
+    });
     std::unique_ptr<GLRenderTimeQuery> renderTime;
 
     if (usingGl) {
@@ -398,9 +404,6 @@ void OffscreenQuickView::update(OutputFrame *frame)
             frame->addRenderTimeQuery(std::move(renderTime));
         }
         d->m_glcontext->doneCurrent();
-        if (previousContext) {
-            (void)previousContext->makeCurrent();
-        }
     }
     d->m_item->scheduleRepaint(d->m_item->rect());
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.