aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickstates
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quick/qquickstates')
-rw-r--r--tests/auto/quick/qquickstates/data/revertListMemoryLeak.qml16
-rw-r--r--tests/auto/quick/qquickstates/tst_qquickstates.cpp25
2 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickstates/data/revertListMemoryLeak.qml b/tests/auto/quick/qquickstates/data/revertListMemoryLeak.qml
new file mode 100644
index 0000000000..b49487c895
--- /dev/null
+++ b/tests/auto/quick/qquickstates/data/revertListMemoryLeak.qml
@@ -0,0 +1,16 @@
+import QtQuick 2.0
+
+Item {
+ id: rect
+ width: 40;
+ property real boundHeight: 42
+ height: boundHeight;
+
+ states: [
+ State {
+ objectName: "testState"
+ name: "testState"
+ PropertyChanges { target: rect; height: 60; }
+ }
+ ]
+}
diff --git a/tests/auto/quick/qquickstates/tst_qquickstates.cpp b/tests/auto/quick/qquickstates/tst_qquickstates.cpp
index 51fe9b4c96..6c42a7a0ee 100644
--- a/tests/auto/quick/qquickstates/tst_qquickstates.cpp
+++ b/tests/auto/quick/qquickstates/tst_qquickstates.cpp
@@ -141,6 +141,7 @@ private slots:
void avoidFastForward();
void revertListBug();
void QTBUG_38492();
+ void revertListMemoryLeak();
};
void tst_qquickstates::initTestCase()
@@ -1634,6 +1635,30 @@ void tst_qquickstates::QTBUG_38492()
delete item;
}
+void tst_qquickstates::revertListMemoryLeak()
+{
+ QWeakPointer<QQmlAbstractBinding> weakPtr;
+ {
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("revertListMemoryLeak.qml"));
+ QQuickItem *item = qobject_cast<QQuickItem *>(c.create());
+ QVERIFY(item);
+ QQuickState *state = item->findChild<QQuickState*>("testState");
+ QVERIFY(state);
+
+ item->setState("testState");
+
+ QQmlAbstractBinding *binding = state->bindingInRevertList(item, "height");
+ QVERIFY(binding);
+ weakPtr = QQmlAbstractBinding::getPointer(binding);
+ QVERIFY(!weakPtr.toStrongRef().isNull());
+
+ delete item;
+ }
+ QVERIFY(weakPtr.toStrongRef().isNull());
+}
+
QTEST_MAIN(tst_qquickstates)
#include "tst_qquickstates.moc"