Fix leaking resources by OpenVG scene graph backend

Change-Id: I4e67c639d8343e39673ef5ea08bda7af033fb19f
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
This commit is contained in:
Kirill Burtsev 2018-11-13 13:38:15 +01:00 committed by Shawn Rutledge
parent 064f0d3d23
commit e746e55f24
3 changed files with 16 additions and 5 deletions

View File

@ -174,7 +174,7 @@ void QSGOpenVGRectangleNode::render()
} }
QSGOpenVGImageNode::QSGOpenVGImageNode() QSGOpenVGImageNode::QSGOpenVGImageNode() : m_texture(nullptr), m_owns(false)
{ {
// Set Dummy material and geometry to avoid asserts // Set Dummy material and geometry to avoid asserts
setMaterial((QSGMaterial*)1); setMaterial((QSGMaterial*)1);
@ -184,9 +184,8 @@ QSGOpenVGImageNode::QSGOpenVGImageNode()
QSGOpenVGImageNode::~QSGOpenVGImageNode() QSGOpenVGImageNode::~QSGOpenVGImageNode()
{ {
if (m_owns) { if (m_owns)
m_texture->deleteLater(); delete m_texture;
}
} }
void QSGOpenVGImageNode::setRect(const QRectF &rect) void QSGOpenVGImageNode::setRect(const QRectF &rect)
@ -212,6 +211,8 @@ QRectF QSGOpenVGImageNode::sourceRect() const
void QSGOpenVGImageNode::setTexture(QSGTexture *texture) void QSGOpenVGImageNode::setTexture(QSGTexture *texture)
{ {
if (m_owns)
delete m_texture;
m_texture = texture; m_texture = texture;
markDirty(DirtyMaterial); markDirty(DirtyMaterial);
} }
@ -321,7 +322,7 @@ void QSGOpenVGImageNode::render()
} }
QSGOpenVGNinePatchNode::QSGOpenVGNinePatchNode() QSGOpenVGNinePatchNode::QSGOpenVGNinePatchNode() : m_texture(nullptr)
{ {
// Set Dummy material and geometry to avoid asserts // Set Dummy material and geometry to avoid asserts
setMaterial((QSGMaterial*)1); setMaterial((QSGMaterial*)1);
@ -329,8 +330,14 @@ QSGOpenVGNinePatchNode::QSGOpenVGNinePatchNode()
} }
QSGOpenVGNinePatchNode::~QSGOpenVGNinePatchNode()
{
delete m_texture;
}
void QSGOpenVGNinePatchNode::setTexture(QSGTexture *texture) void QSGOpenVGNinePatchNode::setTexture(QSGTexture *texture)
{ {
delete m_texture;
m_texture = texture; m_texture = texture;
markDirty(DirtyMaterial); markDirty(DirtyMaterial);
} }

View File

@ -118,6 +118,7 @@ class QSGOpenVGNinePatchNode : public QSGNinePatchNode, public QSGOpenVGRenderab
{ {
public: public:
QSGOpenVGNinePatchNode(); QSGOpenVGNinePatchNode();
~QSGOpenVGNinePatchNode();
void setTexture(QSGTexture *texture) override; void setTexture(QSGTexture *texture) override;
void setBounds(const QRectF &bounds) override; void setBounds(const QRectF &bounds) override;

View File

@ -43,6 +43,7 @@
#include <QtCore/QCoreApplication> #include <QtCore/QCoreApplication>
#include <QtCore/QElapsedTimer> #include <QtCore/QElapsedTimer>
#include <private/qquickanimatorcontroller_p.h>
#include <private/qquickwindow_p.h> #include <private/qquickwindow_p.h>
#include <private/qquickprofiler_p.h> #include <private/qquickprofiler_p.h>
@ -94,6 +95,8 @@ void QSGOpenVGRenderLoop::windowDestroyed(QQuickWindow *window)
} else if (vg && window == vg->window()) { } else if (vg && window == vg->window()) {
vg->doneCurrent(); vg->doneCurrent();
} }
delete d->animationController;
} }
void QSGOpenVGRenderLoop::exposureChanged(QQuickWindow *window) void QSGOpenVGRenderLoop::exposureChanged(QQuickWindow *window)