void QSGSimpleTextureNode::setTexture(QSGTexture *texture)
{
Q_ASSERT(texture);
+ Q_D(QSGSimpleTextureNode);
+ if (d->ownsTexture)
+ delete m_material.texture();
m_material.setTexture(texture);
m_opaque_material.setTexture(texture);
- Q_D(QSGSimpleTextureNode);
qsgsimpletexturenode_update(&m_geometry, texture, m_rect, d->sourceRect, d->texCoordMode);
DirtyState dirty = DirtyMaterial;
QVERIFY(!texture.isNull());
}
- { // Check that it is deleted when we so desire
+ { // Check that it is deleted on destruction when we so desire
QPointer<QSGTexture> texture(new QSGPlainTexture());
QSGSimpleTextureNode *tn = new QSGSimpleTextureNode();
delete tn;
QVERIFY(texture.isNull());
}
+
+ { // Check that it is deleted on update when we so desire
+ QPointer<QSGTexture> oldTexture(new QSGPlainTexture());
+ QPointer<QSGTexture> newTexture(new QSGPlainTexture());
+
+ QSGSimpleTextureNode *tn = new QSGSimpleTextureNode();
+ tn->setOwnsTexture(true);
+ QVERIFY(tn->ownsTexture());
+
+ tn->setTexture(oldTexture);
+ QVERIFY(!oldTexture.isNull());
+ QVERIFY(!newTexture.isNull());
+
+ tn->setTexture(newTexture);
+ QVERIFY(oldTexture.isNull());
+ QVERIFY(!newTexture.isNull());
+
+ delete tn;
+ }
}
void NodesTest::textureNodeRect()