summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2011-12-06 12:55:41 +0100
committerQt by Nokia <qt-info@nokia.com>2011-12-07 11:15:28 +0100
commitbab5329437e6e80da7e9f30d6422ac53f4f33f6d (patch)
tree4003aab018d087c5c7862ba1c6f6e831bf0b4435 /src/plugins/platforms
parent77fb1c71bf9bb576cfb3d7f5bf887325841ebd75 (diff)
Better handling of GLX / EGL errors.
If context creation fails, try again without a shared context. Added QPlatformOpenGLContext::isSharing() and QPlatformOpenGLContext::isValid() to propagate whether the platform context was successfully created with or without sharing. Change-Id: I37080b645f531fd207946441057be6d3f6be3f6e Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/xcb/qglxintegration.cpp26
-rw-r--r--src/plugins/platforms/xcb/qglxintegration.h3
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp7
3 files changed, 31 insertions, 5 deletions
diff --git a/src/plugins/platforms/xcb/qglxintegration.cpp b/src/plugins/platforms/xcb/qglxintegration.cpp
index 550a5e4184..de41f862bd 100644
--- a/src/plugins/platforms/xcb/qglxintegration.cpp
+++ b/src/plugins/platforms/xcb/qglxintegration.cpp
@@ -65,13 +65,21 @@ QGLXContext::QGLXContext(QXcbScreen *screen, const QSurfaceFormat &format, QPlat
, m_screen(screen)
, m_context(0)
{
- GLXContext shareGlxContext = 0;
+ m_shareContext = 0;
if (share)
- shareGlxContext = static_cast<const QGLXContext*>(share)->glxContext();
+ m_shareContext = static_cast<const QGLXContext*>(share)->glxContext();
GLXFBConfig config = qglx_findConfig(DISPLAY_FROM_XCB(screen),screen->screenNumber(),format);
- m_context = glXCreateNewContext(DISPLAY_FROM_XCB(screen), config, GLX_RGBA_TYPE, shareGlxContext, TRUE);
- m_format = qglx_surfaceFormatFromGLXFBConfig(DISPLAY_FROM_XCB(screen), config, m_context);
+
+ m_context = glXCreateNewContext(DISPLAY_FROM_XCB(screen), config, GLX_RGBA_TYPE, m_shareContext, TRUE);
+ if (!m_context && m_shareContext) {
+ // re-try without a shared glx context
+ m_shareContext = 0;
+ m_context = glXCreateNewContext(DISPLAY_FROM_XCB(screen), config, GLX_RGBA_TYPE, 0, TRUE);
+ }
+
+ if (m_context)
+ m_format = qglx_surfaceFormatFromGLXFBConfig(DISPLAY_FROM_XCB(screen), config, m_context);
}
QGLXContext::~QGLXContext()
@@ -137,4 +145,14 @@ QSurfaceFormat QGLXContext::format() const
return m_format;
}
+bool QGLXContext::isSharing() const
+{
+ return m_shareContext != 0;
+}
+
+bool QGLXContext::isValid() const
+{
+ return m_context != 0;
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/qglxintegration.h b/src/plugins/platforms/xcb/qglxintegration.h
index 2c8fea5874..211a654c03 100644
--- a/src/plugins/platforms/xcb/qglxintegration.h
+++ b/src/plugins/platforms/xcb/qglxintegration.h
@@ -66,12 +66,15 @@ public:
void (*getProcAddress(const QByteArray &procName)) ();
QSurfaceFormat format() const;
+ bool isSharing() const;
+ bool isValid() const;
GLXContext glxContext() const { return m_context; }
private:
QXcbScreen *m_screen;
GLXContext m_context;
+ GLXContext m_shareContext;
QSurfaceFormat m_format;
};
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp
index a5b8aa9a35..6969124b2a 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -86,6 +86,11 @@ extern "C" {
QT_BEGIN_NAMESPACE
+static int nullErrorHandler(Display *, XErrorEvent *)
+{
+ return 0;
+}
+
QXcbConnection::QXcbConnection(const char *displayName)
: m_displayName(displayName ? QByteArray(displayName) : qgetenv("DISPLAY"))
#ifdef XCB_USE_XINPUT2_MAEMO
@@ -106,6 +111,7 @@ QXcbConnection::QXcbConnection(const char *displayName)
m_primaryScreen = DefaultScreen(dpy);
m_connection = XGetXCBConnection(dpy);
XSetEventQueueOwner(dpy, XCBOwnsEventQueue);
+ XSetErrorHandler(nullErrorHandler);
m_xlib_display = dpy;
#ifdef XCB_USE_EGL
EGLDisplay eglDisplay = eglGetDisplay(dpy);
@@ -1002,7 +1008,6 @@ void QXcbConnection::initializeXFixes()
xfixes_first_event = 0;
}
free(xfixes_query);
-
}
void QXcbConnection::initializeXRender()