Check whether current context can be obtained when deleting textures.
authorFriedemann Kleint <Friedemann.Kleint@digia.com>
Thu, 6 Nov 2014 15:24:57 +0000 (16:24 +0100)
committerFriedemann Kleint <Friedemann.Kleint@digia.com>
Thu, 6 Nov 2014 17:19:15 +0000 (18:19 +0100)
Add a warning in that case.

Task-number: QTBUG-41966
Change-Id: I491ee9e13c9504040ab789951656983a736d9203
Reviewed-by: Yoann Lopes <yoann.lopes@theqtcompany.com>
src/plugins/wmf/evrd3dpresentengine.cpp
src/qtmultimediaquicktools/qsgvideonode_i420.cpp

index 42d0dea..9a50852 100644 (file)
@@ -184,8 +184,12 @@ D3DPresentEngine::~D3DPresentEngine()
         m_egl->destroySurface(m_eglDisplay, m_eglSurface);
         m_eglSurface = NULL;
     }
-    if (m_glTexture)
-        QOpenGLContext::currentContext()->functions()->glDeleteTextures(1, &m_glTexture);
+    if (m_glTexture) {
+        if (QOpenGLContext *current = QOpenGLContext::currentContext())
+            current->functions()->glDeleteTextures(1, &m_glTexture);
+        else
+            qWarning() << "D3DPresentEngine: Cannot obtain GL context, unable to delete textures";
+    }
 
     delete m_glContext;
     delete m_offscreenSurface;
index 5b8b7ce..17b4924 100644 (file)
@@ -227,8 +227,12 @@ QSGVideoMaterial_YUV420::QSGVideoMaterial_YUV420(const QVideoSurfaceFormat &form
 
 QSGVideoMaterial_YUV420::~QSGVideoMaterial_YUV420()
 {
-    if (!m_textureSize.isEmpty())
-        QOpenGLContext::currentContext()->functions()->glDeleteTextures(Num_Texture_IDs, m_textureIds);
+    if (!m_textureSize.isEmpty()) {
+        if (QOpenGLContext *current = QOpenGLContext::currentContext())
+            current->functions()->glDeleteTextures(Num_Texture_IDs, m_textureIds);
+        else
+            qWarning() << "QSGVideoMaterial_YUV420: Cannot obtain GL context, unable to delete textures";
+    }
 }
 
 void QSGVideoMaterial_YUV420::bind()