Safely abort when we don't succeed in creating a GL context.
authorGunnar Sletta <gunnar.sletta@digia.com>
Tue, 12 Nov 2013 15:53:47 +0000 (16:53 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Tue, 3 Dec 2013 07:42:49 +0000 (08:42 +0100)
Task-number: QTBUG-33363
(cherry-picked from commit 12eab9162781)

Change-Id: Ia2b0c329157786cb4ec703989f12d2fdb1ce6bc8
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
src/quick/scenegraph/qsgrenderloop.cpp
src/quick/scenegraph/qsgwindowsrenderloop.cpp

index 9c39ef6..aa0d7b5 100644 (file)
@@ -277,6 +277,7 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window)
         if (QSGContext::sharedOpenGLContext())
             gl->setShareContext(QSGContext::sharedOpenGLContext());
         if (!gl->create()) {
+            qWarning("QtQuick: failed to create OpenGL context");
             delete gl;
             gl = 0;
         } else {
index 03ee499..0c128d5 100644 (file)
@@ -180,13 +180,20 @@ void QSGWindowsRenderLoop::show(QQuickWindow *window)
         m_gl->setFormat(window->requestedFormat());
         if (QSGContext::sharedOpenGLContext())
             m_gl->setShareContext(QSGContext::sharedOpenGLContext());
-        m_gl->create();
+        bool created = m_gl->create();
+        if (!created) {
+            qWarning("QtQuick: failed to create OpenGL context");
+            delete m_gl;
+            m_gl = 0;
+            return;
+        }
         QSG_RENDER_TIMING_SAMPLE(time_created);
         RLDEBUG(" - making current");
-        m_gl->makeCurrent(window);
+        bool current = m_gl->makeCurrent(window);
         RLDEBUG(" - initializing SG");
         QSG_RENDER_TIMING_SAMPLE(time_current);
-        QQuickWindowPrivate::get(window)->context->initialize(m_gl);
+        if (current)
+            m_rc->initialize(m_gl);
 
 #ifndef QSG_NO_RENDER_TIMING
         if (qsg_render_timing) {