Blame SOURCES/0007-Do-not-try-to-eglMakeCurrent-for-unintended-case.patch

429548
From 2c0a03e9aea13831d05ac03996949f888afd5085 Mon Sep 17 00:00:00 2001
429548
From: Jaehak Lee <jaehak.lee@mobis.co.kr>
429548
Date: Sun, 8 Nov 2020 11:40:06 +0900
429548
Subject: [PATCH 07/36] Do not try to eglMakeCurrent for unintended case
429548
429548
The QSGThreadedRenderLoop::hide can be called at twice,
429548
when the QWindowPrivate::setVisible(false) is called.
429548
429548
The eglSurface is EGL_NO_SURFACE when the second QSGThreadedRenderLoop::hide is
429548
called. And if EGL_KHR_surfaceless_context is supported, the eglMakeCurrent
429548
don't return the false.
429548
429548
But this case is not intended. So, add the defence code for above case.
429548
429548
Fixes: QTBUG-88277
429548
Change-Id: Ia9e5990303e98f0eedc48531e5af62ff9961f419
429548
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
429548
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
429548
---
429548
 .../client/wayland-egl/qwaylandglcontext.cpp                | 6 ++++++
429548
 .../client/wayland-egl/qwaylandglcontext.h                  | 1 +
429548
 2 files changed, 7 insertions(+)
429548
429548
diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp
429548
index ccebf43d..681f82f4 100644
429548
--- a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp
429548
+++ b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp
429548
@@ -336,6 +336,8 @@ QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, QWaylandDisplay *dis
429548
                                << "It may also cause the event loop to freeze in some situations";
429548
     }
429548
 
429548
+    m_supportSurfaceLessContext = q_hasEglExtension(m_eglDisplay, "EGL_KHR_surfaceless_context");
429548
+
429548
     updateGLFormat();
429548
 }
429548
 
429548
@@ -439,6 +441,10 @@ bool QWaylandGLContext::makeCurrent(QPlatformSurface *surface)
429548
         eglSurface = window->eglSurface();
429548
     }
429548
 
429548
+    if (eglSurface == EGL_NO_SURFACE && m_supportSurfaceLessContext) {
429548
+        return false;
429548
+    }
429548
+
429548
     if (!eglMakeCurrent(m_eglDisplay, eglSurface, eglSurface, m_context)) {
429548
         qWarning("QWaylandGLContext::makeCurrent: eglError: %x, this: %p \n", eglGetError(), this);
429548
         window->setCanResize(true);
429548
diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.h b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.h
429548
index 46c7bb76..93edaec0 100644
429548
--- a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.h
429548
+++ b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.h
429548
@@ -93,6 +93,7 @@ private:
429548
     DecorationsBlitter *m_blitter = nullptr;
429548
     uint m_api;
429548
     bool m_supportNonBlockingSwap = true;
429548
+    bool m_supportSurfaceLessContext = false;
429548
 };
429548
 
429548
 }
429548
-- 
429548
2.33.1
429548