diff options
author | Samuel Rødal <samuel.rodal@nokia.com> | 2012-08-21 17:36:03 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-08-22 09:08:02 +0200 |
commit | 015a5e0dcad0bca55d10822f6300b77a95fb69d6 (patch) | |
tree | 3fcbd9ccd4892f5c94ffadd7a532e5d03039f698 /src/plugins | |
parent | 1ed82516674cb44671d247bc025e8c6c7cd3d0d0 (diff) |
Fixed non-GL applications crashing when GLX/EGL initialization fails on xcb.
Change-Id: I5a08d6067272575aa56074aaebe308c3d49299bb
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbwindow.cpp | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 370db82a07..7020e63b0e 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -238,7 +238,7 @@ void QXcbWindow::create() { #if defined(XCB_USE_GLX) XVisualInfo *visualInfo = qglx_findVisualInfo(DISPLAY_FROM_XCB(m_screen), m_screen->screenNumber(), &m_format); - if (!visualInfo) + if (!visualInfo && window()->surfaceType() == QSurface::OpenGLSurface) qFatal("Could not initialize GLX"); #elif defined(XCB_USE_EGL) EGLDisplay eglDisplay = connection()->egl_display(); @@ -254,26 +254,30 @@ void QXcbWindow::create() XVisualInfo *visualInfo; int matchingCount = 0; visualInfo = XGetVisualInfo(DISPLAY_FROM_XCB(this), VisualIDMask, &visualInfoTemplate, &matchingCount); - if (!visualInfo) + if (!visualInfo && window()->surfaceType() == QSurface::OpenGLSurface) qFatal("Could not initialize EGL"); #endif //XCB_USE_GLX - m_depth = visualInfo->depth; - m_imageFormat = imageFormatForDepth(m_depth); - Colormap cmap = XCreateColormap(DISPLAY_FROM_XCB(this), xcb_parent_id, visualInfo->visual, AllocNone); + if (visualInfo) { + m_depth = visualInfo->depth; + m_imageFormat = imageFormatForDepth(m_depth); + Colormap cmap = XCreateColormap(DISPLAY_FROM_XCB(this), xcb_parent_id, visualInfo->visual, AllocNone); + + XSetWindowAttributes a; + a.background_pixel = WhitePixel(DISPLAY_FROM_XCB(this), m_screen->screenNumber()); + a.border_pixel = BlackPixel(DISPLAY_FROM_XCB(this), m_screen->screenNumber()); + a.colormap = cmap; - XSetWindowAttributes a; - a.background_pixel = WhitePixel(DISPLAY_FROM_XCB(this), m_screen->screenNumber()); - a.border_pixel = BlackPixel(DISPLAY_FROM_XCB(this), m_screen->screenNumber()); - a.colormap = cmap; + m_visualId = visualInfo->visualid; - m_visualId = visualInfo->visualid; + m_window = XCreateWindow(DISPLAY_FROM_XCB(this), xcb_parent_id, rect.x(), rect.y(), rect.width(), rect.height(), + 0, visualInfo->depth, InputOutput, visualInfo->visual, + CWBackPixel|CWBorderPixel|CWColormap, &a); - m_window = XCreateWindow(DISPLAY_FROM_XCB(this), xcb_parent_id, rect.x(), rect.y(), rect.width(), rect.height(), - 0, visualInfo->depth, InputOutput, visualInfo->visual, - CWBackPixel|CWBorderPixel|CWColormap, &a); + XFree(visualInfo); + } + } - XFree(visualInfo); - } else + if (!m_window) #endif //defined(XCB_USE_GLX) || defined(XCB_USE_EGL) { m_window = xcb_generate_id(xcb_connection()); @@ -409,6 +413,7 @@ void QXcbWindow::destroy() } connection()->removeWindow(m_window); Q_XCB_CALL(xcb_destroy_window(xcb_connection(), m_window)); + m_window = 0; } m_mapped = false; |