https://invent.kde.org/plasma/kwin/-/merge_requests/7525

From 87fa6e16c7b744f3e92856eb0dbb3f20943403ff Mon Sep 17 00:00:00 2001
From: Xaver Hugl <xaver.hugl@gmail.com>
Date: Thu, 17 Apr 2025 13:17:09 +0000
Subject: [PATCH] opengl/eglcontext: only delete the vao if the context is
 current

Making the context can fail during a GPU reset, and then we'd crash trying
to access the OpenGL function.

This fixes https://crash-reports.kde.org/share/issue/425cb2a56d6d4cdeadfc9e985726a7e8/


(cherry picked from commit 8dbfdb9420c227b8be729dfa6265f6212359ca45)

Co-authored-by: Xaver Hugl <xaver.hugl@gmail.com>
---
 src/opengl/eglcontext.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/opengl/eglcontext.cpp b/src/opengl/eglcontext.cpp
index 48017391281..f1f9a4e3fa6 100644
--- a/src/opengl/eglcontext.cpp
+++ b/src/opengl/eglcontext.cpp
@@ -71,8 +71,8 @@ EglContext::EglContext(EglDisplay *display, EGLConfig config, ::EGLContext conte
 
 EglContext::~EglContext()
 {
-    makeCurrent();
-    if (m_vao) {
+    const bool current = makeCurrent();
+    if (m_vao && current) {
         glDeleteVertexArrays(1, &m_vao);
     }
     m_shaderManager.reset();
-- 
GitLab

