From d21c096f358eaf4dd7245680f38b836bebe43da5 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Mon, 20 Oct 2014 13:07:21 +0200 Subject: Fix crash in SpriteSequence When QML declares sprites and goalSprite in wrong order the goalsprite attempts to set it on null spriteEngine. This patch ensures that the order doesn't matter anymore. Task-number: QTBUG-40595 Change-Id: I57f1c8754b2e2af91e0c7f72d1d67fec3ad4ede5 Reviewed-by: Lars Knoll --- .../qquickspritesequence/data/spriteaftergoal.qml | 60 ++++++++++++++++++++++ .../qquickspritesequence/data/spritebeforegoal.qml | 60 ++++++++++++++++++++++ .../tst_qquickspritesequence.cpp | 26 ++++++++++ 3 files changed, 146 insertions(+) create mode 100644 tests/auto/quick/qquickspritesequence/data/spriteaftergoal.qml create mode 100644 tests/auto/quick/qquickspritesequence/data/spritebeforegoal.qml (limited to 'tests') diff --git a/tests/auto/quick/qquickspritesequence/data/spriteaftergoal.qml b/tests/auto/quick/qquickspritesequence/data/spriteaftergoal.qml new file mode 100644 index 0000000000..189458ad90 --- /dev/null +++ b/tests/auto/quick/qquickspritesequence/data/spriteaftergoal.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// QTBUG-40595 +import QtQuick 2.0 + +Rectangle { + width: 320 + height: 320 + + SpriteSequence + { + anchors.centerIn: parent + + width: 300 + height: 300 + + goalSprite: "foobar" + + sprites: + [ + Sprite + { + name: "foobar" + source: "squarefacesprite.png" + } + ] + } +} + diff --git a/tests/auto/quick/qquickspritesequence/data/spritebeforegoal.qml b/tests/auto/quick/qquickspritesequence/data/spritebeforegoal.qml new file mode 100644 index 0000000000..23326fb5cc --- /dev/null +++ b/tests/auto/quick/qquickspritesequence/data/spritebeforegoal.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// QTBUG-40595 +import QtQuick 2.0 + +Rectangle { + width: 320 + height: 320 + + SpriteSequence + { + anchors.centerIn: parent + + width: 300 + height: 300 + + sprites: + [ + Sprite + { + name: "foobar" + source: "squarefacesprite.png" + } + ] + + goalSprite: "foobar" + } +} + diff --git a/tests/auto/quick/qquickspritesequence/tst_qquickspritesequence.cpp b/tests/auto/quick/qquickspritesequence/tst_qquickspritesequence.cpp index 6cfdc90364..26ddff1009 100644 --- a/tests/auto/quick/qquickspritesequence/tst_qquickspritesequence.cpp +++ b/tests/auto/quick/qquickspritesequence/tst_qquickspritesequence.cpp @@ -46,6 +46,8 @@ private slots: void test_framerateAdvance();//Separate codepath for QQuickSpriteEngine void test_huge();//Separate codepath for QQuickSpriteEngine void test_jumpToCrash(); + void test_spriteBeforeGoal(); + void test_spriteAfterGoal(); }; void tst_qquickspritesequence::test_properties() @@ -119,6 +121,30 @@ void tst_qquickspritesequence::test_jumpToCrash() delete window; } +void tst_qquickspritesequence::test_spriteBeforeGoal() +{ + QQuickView *window = new QQuickView(0); + + window->setSource(testFileUrl("spritebeforegoal.qml")); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + //verify: Don't crash + + delete window; +} + +void tst_qquickspritesequence::test_spriteAfterGoal() +{ + QQuickView *window = new QQuickView(0); + + window->setSource(testFileUrl("spriteaftergoal.qml")); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + //verify: Don't crash + + delete window; +} + QTEST_MAIN(tst_qquickspritesequence) #include "tst_qquickspritesequence.moc" -- cgit v1.2.3