Handle unset $DISPLAY variable when using the offscreen platform
Skip the initialization of a QOffscreenX11GLXContext and thereby fix a null pointer dereference if the environment variable $DISPLAY is unset or contains invalid information. Task-number: QTBUG-66423 Change-Id: Ideea510d1c63a4f6700839955d833cd10e3b0bbe Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
This commit is contained in:
parent
f805be5382
commit
5d3ce3a640
@ -71,6 +71,9 @@ QPlatformOpenGLContext *QOffscreenX11Integration::createPlatformOpenGLContext(QO
|
||||
if (!m_connection)
|
||||
m_connection.reset(new QOffscreenX11Connection);
|
||||
|
||||
if (!m_connection->display())
|
||||
return nullptr;
|
||||
|
||||
return new QOffscreenX11GLXContext(m_connection->x11Info(), context);
|
||||
}
|
||||
|
||||
@ -81,12 +84,13 @@ QOffscreenX11Connection::QOffscreenX11Connection()
|
||||
QByteArray displayName = qgetenv("DISPLAY");
|
||||
Display *display = XOpenDisplay(displayName.constData());
|
||||
m_display = display;
|
||||
m_screenNumber = DefaultScreen(display);
|
||||
m_screenNumber = m_display ? DefaultScreen(m_display) : -1;
|
||||
}
|
||||
|
||||
QOffscreenX11Connection::~QOffscreenX11Connection()
|
||||
{
|
||||
XCloseDisplay((Display *)m_display);
|
||||
if (m_display)
|
||||
XCloseDisplay((Display *)m_display);
|
||||
}
|
||||
|
||||
class QOffscreenX11Info
|
||||
|
Loading…
x
Reference in New Issue
Block a user