Print out a warning when attributes are enabled
authorGunnar Sletta <gunnar.sletta@nokia.com>
Wed, 15 Jun 2011 08:08:43 +0000 (10:08 +0200)
committerGunnar Sletta <gunnar.sletta@nokia.com>
Wed, 15 Jun 2011 08:08:43 +0000 (10:08 +0200)
src/declarative/scenegraph/coreapi/qsgrenderer.cpp

index dbf704b..cc24cc0 100644 (file)
@@ -229,6 +229,21 @@ void QSGRenderer::renderScene(const Bindable &bindable)
     int bindTime = frameTimer.elapsed();
 #endif
 
+#ifndef QT_NO_DEBUG
+    // Sanity check that attribute registers are disabled
+    {
+        GLint count;
+        glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &count);
+        GLint enabled;
+        for (int i=0; i<count; ++i) {
+            glGetVertexAttribiv(i, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &enabled);
+            if (enabled) {
+                qWarning("QSGRenderer: attribute %d is enabled, this can lead to memory corruption and crashes.", i);
+            }
+        }
+    }
+#endif
+
     render();
 #ifdef QSG_RENDERER_TIMING
     int renderTime = frameTimer.elapsed();