Fix crash when running QtWayland compositor on xcb-egl.

When running the compositor on xcb the compositor backend will call
nativeResourceForWindow with EglDisplay as resource. When this is done
the window->handle() will be null and result in a crash. By returning
just the eglDisplay() when the window->handle() is null solves the
problem and also makes the compositor work.

Change-Id: I72f4341402facc8c44a41151c4f76d6447bd8070
Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com>
This commit is contained in:
Erik Larsson 2014-12-24 08:03:37 +01:00 committed by Jørgen Lind
parent b0b2b9c8f7
commit 9a3674302c

View File

@ -116,8 +116,9 @@ void *QXcbEglNativeInterfaceHandler::eglDisplay()
void *QXcbEglNativeInterfaceHandler::eglDisplayForWindow(QWindow *window) void *QXcbEglNativeInterfaceHandler::eglDisplayForWindow(QWindow *window)
{ {
Q_ASSERT(window); Q_ASSERT(window);
Q_ASSERT(window->handle()); if (window->supportsOpenGL() && window->handle() == Q_NULLPTR)
if (window->supportsOpenGL()) return eglDisplay();
else if (window->supportsOpenGL())
return static_cast<QXcbEglWindow *>(window->handle())->glIntegration()->eglDisplay(); return static_cast<QXcbEglWindow *>(window->handle())->glIntegration()->eglDisplay();
return Q_NULLPTR; return Q_NULLPTR;
} }