diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2015-06-25 17:14:40 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2015-06-29 22:54:59 +0000 |
commit | 1e3924d8f585dd9099eb74ffbc17950c693d14da (patch) | |
tree | 62ae3f92f5f14760b2da92af577129f9eef3d3b4 /tests/auto/qmltest/qtbug46798 | |
parent | 89d66647e0b3387b7ef8fbeb1f46b2d4385c3bea (diff) |
Fixed a QQuickListView crash
When an ObjectModel item is removed and destroyed.
Task-number: QTBUG-46798
Change-Id: Ia41dd359d9f3ec5b7af85498dc798f7ab55dca3c
Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Reviewed-by: Alan Alpert <aalpert@blackberry.com>
Diffstat (limited to 'tests/auto/qmltest/qtbug46798')
-rw-r--r-- | tests/auto/qmltest/qtbug46798/tst_qtbug46798.qml | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/tests/auto/qmltest/qtbug46798/tst_qtbug46798.qml b/tests/auto/qmltest/qtbug46798/tst_qtbug46798.qml new file mode 100644 index 0000000000..9de9a621f6 --- /dev/null +++ b/tests/auto/qmltest/qtbug46798/tst_qtbug46798.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.2 +import QtQml.Models 2.3 +import QtTest 1.1 + +Item { + id: top + + ListView { + id: listViewWithObjectModel // QTBUG-46798 + anchors.fill: parent + model: ObjectModel { + id: objectModel + Rectangle { width: 160; height: 160; color: "red" } + Rectangle { width: 160; height: 160; color: "green" } + Rectangle { width: 160; height: 160; color: "blue" } + } + } + + TestCase { + name: "QTBUG-46798" + when: windowShown + + function test_bug46798() { + var item = objectModel.get(0) + if (item) { + objectModel.remove(0) + item.destroy() + } + } + } +} |