From 472950ecab88fc41a99f2a1deb861a4abd273174 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 19 Jul 2013 14:32:17 -0500 Subject: Fix crash when changing non-cached source of image during animation Ensure deferred deletions are handled while syncing, otherwise texture might be deleted after sync but before deferred deletion is processed. Task-number: QTBUG-32513 Change-Id: Id276f536a5722a36baae815b7b550b574eeeb483 Reviewed-by: Gunnar Sletta --- src/quick/scenegraph/qsgthreadedrenderloop.cpp | 4 +- tests/auto/quick/qquickimage/data/qtbug_32513.qml | 63 +++++++++++++++++++++++ tests/auto/quick/qquickimage/tst_qquickimage.cpp | 10 ++++ 3 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 tests/auto/quick/qquickimage/data/qtbug_32513.qml diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp index bfd9a2fb20..1e0d7c5776 100644 --- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp +++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp @@ -535,12 +535,12 @@ void QSGRenderThread::sync() } } + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + RLDEBUG(" Render: - unlocking after sync"); waitCondition.wakeOne(); mutex.unlock(); - - QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); } diff --git a/tests/auto/quick/qquickimage/data/qtbug_32513.qml b/tests/auto/quick/qquickimage/data/qtbug_32513.qml new file mode 100644 index 0000000000..b6cbe33eec --- /dev/null +++ b/tests/auto/quick/qquickimage/data/qtbug_32513.qml @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2013 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:LGPL$ +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + width: 200; height: 200 + + Image { + cache: false + + NumberAnimation on opacity { + loops: Animation.Infinite + from: 1; to: 0 + } + + SequentialAnimation on source { + loops: Animation.Infinite + PropertyAction { value: "green.png" } + PauseAnimation { duration: 100 } + PropertyAction { value: "pattern.png" } + PauseAnimation { duration: 100 } + } + } +} diff --git a/tests/auto/quick/qquickimage/tst_qquickimage.cpp b/tests/auto/quick/qquickimage/tst_qquickimage.cpp index 0804c7b900..8bdb9c9de5 100644 --- a/tests/auto/quick/qquickimage/tst_qquickimage.cpp +++ b/tests/auto/quick/qquickimage/tst_qquickimage.cpp @@ -99,6 +99,7 @@ private slots: void sourceSize_QTBUG_16389(); void nullPixmapPaint(); void imageCrash_QTBUG_22125(); + void imageCrash_QTBUG_32513(); void sourceSize_data(); void sourceSize(); void progressAndStatusChanges(); @@ -704,6 +705,15 @@ void tst_qquickimage::imageCrash_QTBUG_22125() QCoreApplication::processEvents(); } +void tst_qquickimage::imageCrash_QTBUG_32513() +{ + QQuickView view(testFileUrl("qtbug_32513.qml")); + view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + QTest::qWait(1000); + // shouldn't crash when the image changes sources +} + void tst_qquickimage::sourceSize_data() { QTest::addColumn("sourceWidth"); -- cgit v1.2.3