From 8d9c42e36217e14efa69974c2cdc8d90f465a959 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 27 Oct 2016 09:49:24 +0200 Subject: [PATCH] xcb: Avoid crash when requesting non-supported stereo formats Introduced in the 5.7 branch by 5f39a0ef8d037ed8d1fa19d5514308ed4a2ca161. Add also a warning in the GLX backend instead of just dereferencing the null pointer. Task-number: QTBUG-55291 Change-Id: I1f2930768b39a04ee443a68d0ac7dc9ecf26cb9c Reviewed-by: Louai Al-Khanji --- src/platformsupport/glxconvenience/qglxconvenience.cpp | 5 +++++ .../platforms/xcb/gl_integrations/xcb_glx/qxcbglxwindow.cpp | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/src/platformsupport/glxconvenience/qglxconvenience.cpp b/src/platformsupport/glxconvenience/qglxconvenience.cpp index 7dc29fae6d..4225bebf37 100644 --- a/src/platformsupport/glxconvenience/qglxconvenience.cpp +++ b/src/platformsupport/glxconvenience/qglxconvenience.cpp @@ -386,5 +386,10 @@ bool qglx_reduceFormat(QSurfaceFormat *format) return true; } + if (format->stereo()) { + format->setStereo(false); + return true; + } + return false; } diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxwindow.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxwindow.cpp index 8ae83b8084..a8d51d5e8c 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxwindow.cpp +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxwindow.cpp @@ -59,6 +59,10 @@ const xcb_visualtype_t *QXcbGlxWindow::createVisual() if (!scr) return Q_NULLPTR; XVisualInfo *visualInfo = qglx_findVisualInfo(DISPLAY_FROM_XCB(scr), scr->screenNumber(), &m_format); + if (!visualInfo) { + qWarning() << "No XVisualInfo for format" << m_format; + return Q_NULLPTR; + } const xcb_visualtype_t *xcb_visualtype = scr->visualForId(visualInfo->visualid); XFree(visualInfo); return xcb_visualtype;