Only genereate new texture if texture id is 0
authorCharles Yin <charles.yin@nokia.com>
Wed, 16 May 2012 06:05:06 +0000 (16:05 +1000)
committerQt by Nokia <qt-info@nokia.com>
Wed, 16 May 2012 23:13:28 +0000 (01:13 +0200)
Otherwise a new texture would be created for accessing textureId()
function everytime and even worse thing is these textures will never
been deleted and eventually cause gl out of memory.

Change-Id: I349fcf15b5aeabbd9420a8dd645e0fdcc1d256bf
Reviewed-by: Glenn Watson <glenn.watson@nokia.com>
src/quick/scenegraph/util/qsgtexture.cpp

index 69ae317..a380d6e 100644 (file)
@@ -499,7 +499,7 @@ int QSGPlainTexture::textureId() const
             // The actual texture and id will be updated/deleted in a later bind()
             // or ~QSGPlainTexture so just keep it minimal here.
             return 0;
-        } else {
+        } else if (m_texture_id == 0){
             // Generate a texture id for use later and return it.
             glGenTextures(1, &const_cast<QSGPlainTexture *>(this)->m_texture_id);
             return m_texture_id;