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

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