Proper deinitilization of eglImage & texture handles
authorRahul Singhal <rasinghal@nvidia.com>
Thu, 12 May 2011 14:00:29 +0000 (19:30 +0530)
committerMichael Schuldt <michael.schuldt@bmw-carit.de>
Mon, 4 Jul 2011 07:43:50 +0000 (09:43 +0200)
Set eglImage & texture to 0 after they are destroyed/deleted.

LayerManagerPlugins/Renderers/Graphic/src/TextureBinders/X11EglImage.cpp

index 06fa1f5..ceb53d2 100644 (file)
@@ -84,10 +84,12 @@ void X11EglImage::createClientBuffer(Surface* surface)
 
         EGLImageKHR eglImage = 0;
         LOG_DEBUG("X11EglImage", "creating EGL Image from client buffer");
-        if (nativeSurface->eglImage != NULL)
+        if (nativeSurface->eglImage)
         {
             m_pfEglDestroyImageKHR(m_eglDisplay, nativeSurface->eglImage);
             glDeleteTextures(1,&nativeSurface->texture);
+            nativeSurface->eglImage = 0;
+            nativeSurface->texture = 0;
         }
         eglImage = m_pfEglCreateImageKHR(m_eglDisplay,
                                      EGL_NO_CONTEXT,
@@ -101,7 +103,7 @@ void X11EglImage::createClientBuffer(Surface* surface)
         else
         {
             nativeSurface->eglImage = eglImage;
-            glGenTextures(1,&nativeSurface->texture);            
+            glGenTextures(1,&nativeSurface->texture);
         }
     }
 }
@@ -114,9 +116,11 @@ PlatformSurface* X11EglImage::createPlatformSurface(Surface* surface)
 void X11EglImage::destroyClientBuffer(Surface* surface)
 {
     EglXPlatformSurface* nativeSurface = (EglXPlatformSurface*)surface->platform;
-    if (nativeSurface && nativeSurface->eglImage )
+    if (nativeSurface && nativeSurface->eglImage)
     {
-          m_pfEglDestroyImageKHR(m_eglDisplay, nativeSurface->eglImage);
-          glDeleteTextures(1,&nativeSurface->texture);
+        m_pfEglDestroyImageKHR(m_eglDisplay, nativeSurface->eglImage);
+        glDeleteTextures(1,&nativeSurface->texture);
+        nativeSurface->eglImage = 0;
+        nativeSurface->texture = 0;
     }
 }