aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/particles
diff options
context:
space:
mode:
authorMartin T. H. Sandsmark <martin.sandsmark@kde.org>2017-03-12 15:03:56 +0100
committerRobin Burchell <robin.burchell@crimson.no>2017-04-05 20:56:31 +0000
commit8b255c67b965cda334425d64a0f1fd13ace93584 (patch)
treee41a9e8326e7fff9d5915111efb7849af57fe5dd /tests/auto/particles
parent22c39eda8ab316c743d0beac62a9745fd82147f7 (diff)
QQuickParticleSystem: Fix crash when an Affector dies
A guarded pointer wasn't checked before being de-referenced, that lead to a crash if an emitter was modified after an affector was deleted, but before updateCurrentTime() was called. Change-Id: I6cb605a711319fb77c1e2e87fa9f35427cd7797b Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
Diffstat (limited to 'tests/auto/particles')
-rw-r--r--tests/auto/particles/qquickparticlesystem/data/crashaffectors.qml43
-rw-r--r--tests/auto/particles/qquickparticlesystem/tst_qquickparticlesystem.cpp7
2 files changed, 50 insertions, 0 deletions
diff --git a/tests/auto/particles/qquickparticlesystem/data/crashaffectors.qml b/tests/auto/particles/qquickparticlesystem/data/crashaffectors.qml
new file mode 100644
index 0000000000..de105916a7
--- /dev/null
+++ b/tests/auto/particles/qquickparticlesystem/data/crashaffectors.qml
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 reMarkable A/S
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.6
+import QtQuick.Particles 2.0
+
+ParticleSystem {
+ running: false
+ Affector { Component.onCompleted: destroy() }
+ Emitter {
+ Timer { interval: 1; running: true; onTriggered: parent.lifeSpan = 1 }
+ }
+}
diff --git a/tests/auto/particles/qquickparticlesystem/tst_qquickparticlesystem.cpp b/tests/auto/particles/qquickparticlesystem/tst_qquickparticlesystem.cpp
index 5c82b946e5..5f9db12144 100644
--- a/tests/auto/particles/qquickparticlesystem/tst_qquickparticlesystem.cpp
+++ b/tests/auto/particles/qquickparticlesystem/tst_qquickparticlesystem.cpp
@@ -42,6 +42,7 @@ public:
private slots:
void initTestCase();
void test_basic();
+ void test_affectorscrash();
};
void tst_qquickparticlesystem::initTestCase()
@@ -78,6 +79,12 @@ void tst_qquickparticlesystem::test_basic()
delete view;
QVERIFY(extremelyFuzzyCompare(stillAlive, 500, 5));//Small simulation variance is permissible.
}
+void tst_qquickparticlesystem::test_affectorscrash()
+{
+ QScopedPointer<QQuickView> view (createView(testFileUrl("crashaffectors.qml"), 600));
+
+ // This should have crashed by now
+}
QTEST_MAIN(tst_qquickparticlesystem);