From a4db2f731372b40c275eb8e462fbf682d858f609 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 3 Jun 2025 10:03:01 +0200 Subject: [PATCH] QWaylandGLContext: init fields in default ctor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Coverity complains that the =default'ed default ctor leaves m_decorationsContext and m_api uninitialized, which is true. To fix, use NSDMI for the former. For m_api, initialize it in the default constructor's member initializer list, because the default value is closely related to the other constructor's choice of value¹, and so should be more proximal to the other constructor's initialization of m_api (which is dynamic). Using NSDMI for m_api would also remove tooling's ability to detect faults in the other constructor. ¹ I had to track into QSurfaceFormat to verify which of the possible values is the correct one (= the one that gets mapped from DefaultSurfaceFormat by the switch in the other QWaylandGLContext ctor). Amends 7c0a96785fee4fea8ef1452166b1dde88957445c. Task-number: QTBUG-110758 Coverity-Id: 481857 Change-Id: I837d0a3a63bd6e2948ef1c9757e250bfba7dd957 Reviewed-by: Giuseppe D'Angelo Reviewed-by: Edward Welbourne (cherry picked from commit e51675b891d2a4c64dda0094be0c84070833b82a) Reviewed-by: Qt Cherry-pick Bot --- .../hardwareintegration/wayland-egl/qwaylandglcontext.cpp | 7 +++++-- .../hardwareintegration/wayland-egl/qwaylandglcontext_p.h | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandglcontext.cpp b/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandglcontext.cpp index a3e6c534663..54a63566691 100644 --- a/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandglcontext.cpp +++ b/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandglcontext.cpp @@ -191,13 +191,16 @@ public: int m_textureWrap; }; -QWaylandGLContext::QWaylandGLContext() = default; +QWaylandGLContext::QWaylandGLContext() + : QEGLPlatformContext(), + m_api(EGL_OPENGL_ES_API) +{ +} QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, QWaylandDisplay *display, const QSurfaceFormat &fmt, QPlatformOpenGLContext *share) : QEGLPlatformContext(fmt, share, eglDisplay) , m_display(display) - , m_decorationsContext(EGL_NO_CONTEXT) { m_reconnectionWatcher = QObject::connect(m_display, &QWaylandDisplay::connected, m_display, [this] { invalidateContext(); }); diff --git a/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandglcontext_p.h b/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandglcontext_p.h index e653e60e215..9da8e10a66f 100644 --- a/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandglcontext_p.h +++ b/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandglcontext_p.h @@ -57,7 +57,7 @@ protected: private: QWaylandDisplay *m_display = nullptr; - EGLContext m_decorationsContext; + EGLContext m_decorationsContext = EGL_NO_CONTEXT; DecorationsBlitter *m_blitter = nullptr; bool m_supportNonBlockingSwap = true; EGLenum m_api;