diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2014-05-03 14:57:01 +0200 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2014-05-05 09:45:27 +0300 |
commit | d6c1aadb3ee366ce8fd40da43fb65128ab3b2d44 (patch) | |
tree | 5a0a679c02738138aaad95b8a1311c71b4bd6d23 | |
parent | 370705e2246df38f1c3e83fe7231e61a611738ea (diff) |
Fix some simple memory leaks
Make sure all GLint arrays get deleted and also with delete [].
Change-Id: I5ec46eed85f78aee87696986b96ef02f201a9be3
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>
-rw-r--r-- | src/datavisualizationqml2/glstatestore.cpp | 16 | ||||
-rw-r--r-- | src/datavisualizationqml2/glstatestore_p.h | 15 |
2 files changed, 15 insertions, 16 deletions
diff --git a/src/datavisualizationqml2/glstatestore.cpp b/src/datavisualizationqml2/glstatestore.cpp index f053078b..6fbd3a34 100644 --- a/src/datavisualizationqml2/glstatestore.cpp +++ b/src/datavisualizationqml2/glstatestore.cpp @@ -50,13 +50,13 @@ GLStateStore::GLStateStore(QOpenGLContext *context, QObject *parent) : #endif m_maxVertexAttribs = qMin(maxVertexAttribs, 2); // Datavis only uses 2 attribs max - m_vertexAttribArrayEnabledStates = new GLint[maxVertexAttribs]; - m_vertexAttribArrayBoundBuffers = new GLint[maxVertexAttribs]; - m_vertexAttribArraySizes = new GLint[maxVertexAttribs]; - m_vertexAttribArrayTypes = new GLint[maxVertexAttribs]; - m_vertexAttribArrayNormalized = new GLint[maxVertexAttribs]; - m_vertexAttribArrayStrides = new GLint[maxVertexAttribs]; - m_vertexAttribArrayOffsets = new GLint[maxVertexAttribs]; + m_vertexAttribArrayEnabledStates.reset(new GLint[maxVertexAttribs]); + m_vertexAttribArrayBoundBuffers.reset(new GLint[maxVertexAttribs]); + m_vertexAttribArraySizes.reset(new GLint[maxVertexAttribs]); + m_vertexAttribArrayTypes.reset(new GLint[maxVertexAttribs]); + m_vertexAttribArrayNormalized.reset(new GLint[maxVertexAttribs]); + m_vertexAttribArrayStrides.reset(new GLint[maxVertexAttribs]); + m_vertexAttribArrayOffsets.reset(new GLint[maxVertexAttribs]); initGLDefaultState(); } @@ -67,8 +67,6 @@ GLStateStore::~GLStateStore() EnumToStringMap::deleteInstance(); m_map = 0; #endif - delete m_vertexAttribArrayEnabledStates; - delete m_vertexAttribArrayBoundBuffers; } void GLStateStore::storeGLState() diff --git a/src/datavisualizationqml2/glstatestore_p.h b/src/datavisualizationqml2/glstatestore_p.h index 14c46c43..c5023657 100644 --- a/src/datavisualizationqml2/glstatestore_p.h +++ b/src/datavisualizationqml2/glstatestore_p.h @@ -32,6 +32,7 @@ #include <QObject> #include <QtGui/QOpenGLFunctions> #include <QtGui/QOpenGLContext> +#include <QtCore/QScopedArrayPointer> #include "enumtostringmap_p.h" class GLStateStore : public QObject, protected QOpenGLFunctions @@ -66,13 +67,13 @@ public: GLboolean m_isDepthWriteEnabled; GLint m_currentProgram; GLint m_maxVertexAttribs; - GLint *m_vertexAttribArrayEnabledStates; - GLint *m_vertexAttribArrayBoundBuffers; - GLint *m_vertexAttribArraySizes; - GLint *m_vertexAttribArrayTypes; - GLint *m_vertexAttribArrayNormalized; - GLint *m_vertexAttribArrayStrides; - GLint *m_vertexAttribArrayOffsets; + QScopedArrayPointer<GLint> m_vertexAttribArrayEnabledStates; + QScopedArrayPointer<GLint> m_vertexAttribArrayBoundBuffers; + QScopedArrayPointer<GLint> m_vertexAttribArraySizes; + QScopedArrayPointer<GLint> m_vertexAttribArrayTypes; + QScopedArrayPointer<GLint> m_vertexAttribArrayNormalized; + QScopedArrayPointer<GLint> m_vertexAttribArrayStrides; + QScopedArrayPointer<GLint> m_vertexAttribArrayOffsets; GLint m_activeTexture; GLint m_texBinding2D; |