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

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