Fix crash when changing non-cached source of image during animation
authorMichael Brasser <michael.brasser@live.com>
Fri, 19 Jul 2013 19:32:17 +0000 (14:32 -0500)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Thu, 1 Aug 2013 16:45:59 +0000 (18:45 +0200)
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 <gunnar.sletta@digia.com>
src/quick/scenegraph/qsgthreadedrenderloop.cpp
tests/auto/quick/qquickimage/data/qtbug_32513.qml [new file with mode: 0644]
tests/auto/quick/qquickimage/tst_qquickimage.cpp

index bfd9a2f..1e0d7c5 100644 (file)
@@ -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 (file)
index 0000000..b6cbe33
--- /dev/null
@@ -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 }
+        }
+    }
+}
index 0804c7b..8bdb9c9 100644 (file)
@@ -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<int>("sourceWidth");