QWaylandGLContext: init fields in default ctor

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 <giuseppe.dangelo@kdab.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit e51675b891d2a4c64dda0094be0c84070833b82a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2025-06-03 10:03:01 +02:00 committed by Qt Cherry-pick Bot
parent 33f8d08343
commit a4db2f7313
2 changed files with 6 additions and 3 deletions

View File

@ -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(); });

View File

@ -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;