summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMäättä Antti <antti.maatta@theqtcompany.com>2016-04-26 09:53:55 +0300
committerSean Harmer <sean.harmer@kdab.com>2016-04-28 07:50:29 +0000
commit4151ee7970bb0480f9d253e7b08c51086d4237e5 (patch)
tree2e14efe7077bc6c3b180b4f31ee599e3079e4d8b
parent665dcf07d51124a3cb7a7c5bff305eaf66970c75 (diff)
Fix memory leaks in openglvertexarrayobject
Use QScopedPointer to store vao. Task-number: QTBUG-47978 Change-Id: I03b09cf97818c440e2241cdeff78975482463d75 Reviewed-by: Tomi Korpipää <tomi.korpipaa@theqtcompany.com> Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
-rw-r--r--src/render/backend/openglvertexarrayobject_p.h19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/render/backend/openglvertexarrayobject_p.h b/src/render/backend/openglvertexarrayobject_p.h
index fe3233da5..fb67145b8 100644
--- a/src/render/backend/openglvertexarrayobject_p.h
+++ b/src/render/backend/openglvertexarrayobject_p.h
@@ -63,45 +63,44 @@ class OpenGLVertexArrayObject
{
public:
OpenGLVertexArrayObject()
- : m_vao(Q_NULLPTR)
- , m_specified(false)
+ : m_specified(false)
{}
void bind()
{
- Q_ASSERT(m_vao);
+ Q_ASSERT(!m_vao.isNull());
Q_ASSERT(m_vao->isCreated());
m_vao->bind();
}
void release()
{
- Q_ASSERT(m_vao);
+ Q_ASSERT(!m_vao.isNull());
Q_ASSERT(m_vao->isCreated());
m_vao->release();
}
void create()
{
- Q_ASSERT(m_vao);
+ Q_ASSERT(!m_vao.isNull());
m_vao->create();
}
bool isCreated() const
{
- Q_ASSERT(m_vao);
+ Q_ASSERT(!m_vao.isNull());
return m_vao->isCreated();
}
- QOpenGLVertexArrayObject *vao() { return m_vao; }
- const QOpenGLVertexArrayObject *vao() const { return m_vao; }
- void setVao(QOpenGLVertexArrayObject *vao) { m_vao = vao; }
+ QOpenGLVertexArrayObject *vao() { return m_vao.data(); }
+ const QOpenGLVertexArrayObject *vao() const { return m_vao.data(); }
+ void setVao(QOpenGLVertexArrayObject *vao) { m_vao.reset(vao); }
void setSpecified(bool b) { m_specified = b; }
bool isSpecified() const { return m_specified; }
private:
- QOpenGLVertexArrayObject *m_vao;
+ QScopedPointer<QOpenGLVertexArrayObject> m_vao;
bool m_specified;
};