xcb: Avoid crash when requesting non-supported stereo formats

Introduced in the 5.7 branch by 5f39a0ef8d.

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 <louai.al-khanji@qt.io>
This commit is contained in:
Laszlo Agocs 2016-10-27 09:49:24 +02:00
parent af0d0b9c06
commit 8d9c42e362
2 changed files with 9 additions and 0 deletions

View File

@ -386,5 +386,10 @@ bool qglx_reduceFormat(QSurfaceFormat *format)
return true;
}
if (format->stereo()) {
format->setStereo(false);
return true;
}
return false;
}

View File

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