diff options
| author | Assam Boudjelthia <assam.boudjelthia@qt.io> | 2025-08-28 13:56:41 +0300 |
|---|---|---|
| committer | Assam Boudjelthia <assam.boudjelthia@qt.io> | 2025-09-01 21:31:58 +0300 |
| commit | 9ddf467544fd91b72bb12b66e7a3dd80a2121c43 (patch) | |
| tree | eb632292f576cf367c5fac37ec6a84861066d490 /src/plugins/platforms/android/qandroidplatformopenglwindow.cpp | |
| parent | 8a8d64cd7cf265b0ec94686399b42f6871026d34 (diff) | |
Android: ensure ANativeWindow_fromSurface() is called on valid object
Amends b25c1e8452ecffa70b4b75fdb579f08187b36a63.
The above change simplified the logic there but introduced a
potential crash if m_surfaceCreated is true while the surface
m_androidSurfaceObject has not yet been initialized.
Pick-to: 6.10
Change-Id: Ia185aef175022b973614950857aae4e02cb8c0d3
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/plugins/platforms/android/qandroidplatformopenglwindow.cpp')
| -rw-r--r-- | src/plugins/platforms/android/qandroidplatformopenglwindow.cpp | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp b/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp index 066c3a3d8d6..152eb288666 100644 --- a/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp +++ b/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp @@ -71,23 +71,11 @@ EGLSurface QAndroidPlatformOpenGLWindow::eglSurface(EGLConfig config) } if (m_eglSurface == EGL_NO_SURFACE) - createEgl(config); + ensureEglSurfaceCreated(config); return m_eglSurface; } -// m_surfaceMutex already locked, called only by eglSurface() -// and QAndroidPlatformOpenGLContext::swapBuffers(). -bool QAndroidPlatformOpenGLWindow::makeCurrentNeeded() const -{ - // Either no surface created, or the m_eglSurface already wraps the active Surface - // -> makeCurrent is NOT needed, and we should not create a new EGL surface - if (!m_surfaceCreated || !m_androidSurfaceObject.isValid()) - return false; - - return true; -} - void QAndroidPlatformOpenGLWindow::applicationStateChanged(Qt::ApplicationState state) { QAndroidPlatformWindow::applicationStateChanged(state); @@ -101,8 +89,15 @@ void QAndroidPlatformOpenGLWindow::applicationStateChanged(Qt::ApplicationState // m_surfaceMutex already locked, called only by eglSurface() // and QAndroidPlatformOpenGLContext::swapBuffers(). -void QAndroidPlatformOpenGLWindow::createEgl(EGLConfig config) +bool QAndroidPlatformOpenGLWindow::ensureEglSurfaceCreated(EGLConfig config) { + // Either no surface created, or the m_eglSurface already wraps the active Surface, + // so makeCurrent is NOT needed, and we should not create a new EGL surface. + if (!m_surfaceCreated || !m_androidSurfaceObject.isValid()) { + qCDebug(lcQpaWindow) << "Skipping create egl on invalid or not yet created surface"; + return false; + } + clearSurface(); m_nativeWindow = ANativeWindow_fromSurface( QJniEnvironment::getJniEnv(), m_androidSurfaceObject.object()); @@ -117,6 +112,8 @@ void QAndroidPlatformOpenGLWindow::createEgl(EGLConfig config) // we've created another Surface, the window should be repainted sendExpose(); + + return true; } QSurfaceFormat QAndroidPlatformOpenGLWindow::format() const |
