Handle scene graph invalidation
authorGunnar Sletta <gunnar.sletta@jollamobile.com>
Tue, 5 Aug 2014 10:07:42 +0000 (10:07 +0000)
committerGunnar Sletta <gunnar.sletta@jollamobile.com>
Fri, 8 Aug 2014 04:26:33 +0000 (06:26 +0200)
Change-Id: Icff592a4ae48444a36406a65c1c04a3a6da77616
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
src/quick/items/context2d/qquickcanvasitem.cpp
src/quick/items/context2d/qquickcanvasitem_p.h

index 7d3be08..d184003 100644 (file)
@@ -284,6 +284,7 @@ QQuickCanvasItem::QQuickCanvasItem(QQuickItem *parent)
     : QQuickItem(*(new QQuickCanvasItemPrivate), parent)
 {
     setFlag(ItemHasContents);
+    connect(this, SIGNAL(sceneGraphInvalidated()), this, SLOT(invalidateSG()));
 }
 
 QQuickCanvasItem::~QQuickCanvasItem()
@@ -606,6 +607,13 @@ void QQuickCanvasItem::releaseResources()
     }
 }
 
+void QQuickCanvasItem::invalidateSG()
+{
+    Q_D(QQuickCanvasItem);
+    d->context->deleteLater();
+    d->context = 0;
+}
+
 void QQuickCanvasItem::componentComplete()
 {
     QQuickItem::componentComplete();
index 3baf68d..2e17b04 100644 (file)
@@ -164,6 +164,7 @@ public Q_SLOTS:
 private Q_SLOTS:
     void sceneGraphInitialized();
     void checkAnimationCallbacks();
+    void invalidateSG();
 
 protected:
     void componentComplete();