diff options
author | Tobias Koenig <tobias.koenig@kdab.com> | 2015-07-03 10:55:35 +0200 |
---|---|---|
committer | Tobias Koenig <tobias.koenig@kdab.com> | 2015-07-03 17:10:15 +0000 |
commit | eeee9f1466ffaf17f81d635c2e43dca76ce5b021 (patch) | |
tree | cb96f082237e9adb4290b428fcc36a8c6f9554a3 /tests | |
parent | 8b205fd05dcdc4a0e7ec6b25429f691a0a9099fe (diff) |
QSGSimpleTextureNode: Fix ownership of QSGTexture
Make sure the QSGSimpleTextureNode deletes the old QSGTexture
if a new one is set via setTexture() and the ownsTexture flag
is true.
[ChangeLog][QtQuick][SceneGraph] QSGSimpleTextureNode will now delete
the currently set QSGTexture object, if a new QSGTexture is set and
the ownsTexture flag is on.
Change-Id: Iabfbccd390e16948d4575baf29e6c8b4a184a404
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/quick/nodes/tst_nodestest.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/auto/quick/nodes/tst_nodestest.cpp b/tests/auto/quick/nodes/tst_nodestest.cpp index b49ce34951..c49f01d5a7 100644 --- a/tests/auto/quick/nodes/tst_nodestest.cpp +++ b/tests/auto/quick/nodes/tst_nodestest.cpp @@ -283,7 +283,7 @@ void NodesTest::textureNodeTextureOwnership() 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(); @@ -294,6 +294,25 @@ void NodesTest::textureNodeTextureOwnership() 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() |