aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph
diff options
context:
space:
mode:
authorEirik Aavitsland <eirik.aavitsland@qt.io>2019-10-02 09:45:57 +0200
committerEirik Aavitsland <eirik.aavitsland@qt.io>2019-10-07 09:15:05 +0200
commitf4744a77224009cb46a254614106b9034a84fd4f (patch)
tree5961198607ec480ca8331fce537be4235d47257a /src/quick/scenegraph
parent654c48f6746d0c57b4c708bd0e90e86921cc377f (diff)
Fix sprites leaking textures in SW and OpenVG backends
When a QSGSpriteNode is initialized with a texture, it is supposed to take ownership of the texture and delete it when the node gets deleted. In the default backend, this happens automatically: The texture gets assigned to the node's QSGMaterial object, and the node has set the OwnsMaterial flag, and so the inherited QSGGeometry destructor takes care of deleting the material, which deletes the texture. However, the Software and OpenVG backends do not have material objects, so the above mechanism does not apply, and so the texture objects are leaked. Fix by deleting the texture object directly from the SoftwareSpriteNode and OpenVGSpriteNode destructors. Fixes: QTBUG-77019 Change-Id: I503d704f66593ba6a36c969db80f74f715382b6b Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/quick/scenegraph')
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarespritenode.cpp5
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarespritenode_p.h3
2 files changed, 7 insertions, 1 deletions
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarespritenode.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarespritenode.cpp
index d4e5e98d68..17e8bdc2f9 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarespritenode.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarespritenode.cpp
@@ -49,6 +49,11 @@ QSGSoftwareSpriteNode::QSGSoftwareSpriteNode()
setGeometry((QSGGeometry*)1);
}
+QSGSoftwareSpriteNode::~QSGSoftwareSpriteNode()
+{
+ delete m_texture;
+}
+
void QSGSoftwareSpriteNode::setTexture(QSGTexture *texture)
{
m_texture = qobject_cast<QSGSoftwarePixmapTexture*>(texture);
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarespritenode_p.h b/src/quick/scenegraph/adaptations/software/qsgsoftwarespritenode_p.h
index 577a30c051..4015537395 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarespritenode_p.h
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarespritenode_p.h
@@ -64,6 +64,7 @@ class QSGSoftwareSpriteNode : public QSGSpriteNode
{
public:
QSGSoftwareSpriteNode();
+ ~QSGSoftwareSpriteNode() override;
void setTexture(QSGTexture *texture) override;
void setTime(float time) override;
@@ -81,7 +82,7 @@ public:
private:
- QSGSoftwarePixmapTexture *m_texture;
+ QSGSoftwarePixmapTexture *m_texture = nullptr;
float m_time;
QPoint m_sourceA;
QPoint m_sourceB;