aboutsummaryrefslogtreecommitdiffstats
path: root/src/particles/qquickimageparticle.cpp
diff options
context:
space:
mode:
authorJocelyn Turcotte <jocelyn.turcotte@digia.com>2014-10-23 16:01:57 +0200
committerJocelyn Turcotte <jocelyn.turcotte@digia.com>2014-10-27 14:35:26 +0100
commit32af8055985c1f978574eec62512638f472e8290 (patch)
tree875dcea67e2d8289c055ce96ebb8c048dff025ee /src/particles/qquickimageparticle.cpp
parentc7ea1cd9237045e3a8b2b148c57f6d26dd547f7e (diff)
Fix leaks in QQuickImageParticle
Make sure that ImageData instances, m_shadowData as well as the QSGGeometry of particle nodes are destroyed together with their QQuickImageParticle. Also implement the assignment operator for QQuickParticleData to avoid its v8Datum pointer to be copied over to the shadow datum in getShadowDatum. This would cause a double delete of the QQuickV4ParticleData when trying to call clearShadows() in the destructor. Task-number: QTBUG-36782 Change-Id: Ie03f2be0415daeb7f4f6e5f92295a3ab26a62155 Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Diffstat (limited to 'src/particles/qquickimageparticle.cpp')
-rw-r--r--src/particles/qquickimageparticle.cpp23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/particles/qquickimageparticle.cpp b/src/particles/qquickimageparticle.cpp
index 60a67d55a6..50fa9dbc64 100644
--- a/src/particles/qquickimageparticle.cpp
+++ b/src/particles/qquickimageparticle.cpp
@@ -706,10 +706,6 @@ void fillUniformArrayFromImage(float* array, const QImage& img, int size)
QQuickImageParticle::QQuickImageParticle(QQuickItem* parent)
: QQuickParticlePainter(parent)
- , m_image(0)
- , m_colorTable(0)
- , m_sizeTable(0)
- , m_opacityTable(0)
, m_color_variation(0.0)
, m_material(0)
, m_alphaVariation(0.0)
@@ -742,6 +738,7 @@ QQuickImageParticle::QQuickImageParticle(QQuickItem* parent)
QQuickImageParticle::~QQuickImageParticle()
{
+ clearShadows();
}
QQmlListProperty<QQuickSprite> QQuickImageParticle::sprites()
@@ -759,15 +756,14 @@ void QQuickImageParticle::setImage(const QUrl &image)
{
if (image.isEmpty()){
if (m_image) {
- delete m_image;
- m_image = 0;
+ m_image.reset();
emit imageChanged();
}
return;
}
if (!m_image)
- m_image = new ImageData;
+ m_image.reset(new ImageData);
if (image == m_image->source)
return;
m_image->source = image;
@@ -780,14 +776,14 @@ void QQuickImageParticle::setColortable(const QUrl &table)
{
if (table.isEmpty()){
if (m_colorTable) {
- delete m_colorTable;
+ m_colorTable.reset();
emit colortableChanged();
}
return;
}
if (!m_colorTable)
- m_colorTable = new ImageData;
+ m_colorTable.reset(new ImageData);
if (table == m_colorTable->source)
return;
m_colorTable->source = table;
@@ -799,14 +795,14 @@ void QQuickImageParticle::setSizetable(const QUrl &table)
{
if (table.isEmpty()){
if (m_sizeTable) {
- delete m_sizeTable;
+ m_sizeTable.reset();
emit sizetableChanged();
}
return;
}
if (!m_sizeTable)
- m_sizeTable = new ImageData;
+ m_sizeTable.reset(new ImageData);
if (table == m_sizeTable->source)
return;
m_sizeTable->source = table;
@@ -818,14 +814,14 @@ void QQuickImageParticle::setOpacitytable(const QUrl &table)
{
if (table.isEmpty()){
if (m_opacityTable) {
- delete m_opacityTable;
+ m_opacityTable.reset();
emit opacitytableChanged();
}
return;
}
if (!m_opacityTable)
- m_opacityTable = new ImageData;
+ m_opacityTable.reset(new ImageData);
if (table == m_opacityTable->source)
return;
m_opacityTable->source = table;
@@ -1406,6 +1402,7 @@ void QQuickImageParticle::finishBuildParticleNodes(QSGNode** node)
else //Simple
g = new QSGGeometry(SimpleParticle_AttributeSet, count, 0);
+ node->setFlag(QSGNode::OwnsGeometry);
node->setGeometry(g);
if (perfLevel <= Colored){
g->setDrawingMode(GL_POINTS);