aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickitem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/quick/items/qquickitem.cpp')
-rw-r--r--src/quick/items/qquickitem.cpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index 51bec66d22..54c63c4cbf 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -2622,6 +2622,11 @@ void QQuickItemPrivate::refWindow(QQuickWindow *c)
Q_ASSERT(window == 0);
window = c;
+ if (q->flags() & QQuickItem::ItemHasContents) {
+ QObject::connect(window, SIGNAL(sceneGraphInvalidated()), q, SIGNAL(sceneGraphInvalidated()), Qt::DirectConnection);
+ QObject::connect(window, SIGNAL(sceneGraphInitialized()), q, SIGNAL(sceneGraphInitialized()), Qt::DirectConnection);
+ }
+
if (polishScheduled)
QQuickWindowPrivate::get(window)->itemsToPolish.insert(q);
@@ -2651,6 +2656,11 @@ void QQuickItemPrivate::derefWindow()
if (--windowRefCount > 0)
return; // There are still other references, so don't set window to null yet.
+ if (q->flags() & QQuickItem::ItemHasContents) {
+ QObject::disconnect(window, SIGNAL(sceneGraphInvalidated()), q, SIGNAL(sceneGraphInvalidated()));
+ QObject::disconnect(window, SIGNAL(sceneGraphInitialized()), q, SIGNAL(sceneGraphInitialized()));
+ }
+
q->releaseResources();
removeFromDirtyList();
QQuickWindowPrivate *c = QQuickWindowPrivate::get(window);
@@ -5794,10 +5804,67 @@ void QQuickItem::setFlags(Flags flags)
if (int(flags & ItemClipsChildrenToShape) != int(d->flags & ItemClipsChildrenToShape))
d->dirty(QQuickItemPrivate::Clip);
+ if (window() && (flags & ItemHasContents) ^ (d->flags & ItemHasContents)) {
+ if (flags & ItemHasContents) {
+ connect(window(), SIGNAL(sceneGraphInvalidated()), this, SIGNAL(sceneGraphInvalidated()), Qt::DirectConnection);
+ connect(window(), SIGNAL(sceneGraphInitialized()), this, SIGNAL(sceneGraphInitialized()), Qt::DirectConnection);
+ } else {
+ disconnect(window(), SIGNAL(sceneGraphInvalidated()), this, SIGNAL(sceneGraphInvalidated()));
+ disconnect(window(), SIGNAL(sceneGraphInitialized()), this, SIGNAL(sceneGraphInitialized()));
+ }
+ }
+
d->flags = flags;
}
/*!
+ \fn void QQuickItem::sceneGraphInvalidated()
+
+ This signal is emitted when the scene graph is invalidated for
+ items that have the ItemHasContents flag set.
+
+ QSGNode instances will be cleaned up by the scene graph
+ automatically. An application will only need to react to this signal
+ to clean up resources that are stored and managed outside the
+ QSGNode structure returned from updatePaintNode().
+
+ When the scene graph is using a dedicated render thread, this
+ signal will be emitted on the scene graph's render thread. The
+ GUI thread is blocked for the duration of this call. Connections
+ should for this reason be made using Qt::DirectConnection.
+
+ The OpenGL context of this item's window will be bound when this
+ signal is emitted. The only exception is if the native OpenGL has
+ been destroyed outside Qt's control, for instance through
+ EGL_CONTEXT_LOST.
+
+ \since 5.4
+ \since QtQuick 2.4
+
+ \sa QQuickWindow::sceneGraphInvalidated()
+ */
+
+/*!
+ \fn void QQuickItem::sceneGraphInitialized()
+
+ This signal is emitted when the scene graph is is initialized for
+ items that have the ItemHasContents flag set.
+
+ When the scene graph is using a dedicated render thread, this
+ function will be called on the scene graph's render thread. The
+ GUI thread is blocked for the duration of this call. Connections
+ should for this reason be made using Qt::DirectConnection.
+
+ The OpenGL context of this item's window will be bound when
+ this signal is emitted.
+
+ \since 5.4
+ \since QtQuick 2.4
+
+ \sa QQuickWindow::sceneGraphInitialized()
+ */
+
+/*!
\qmlproperty real QtQuick::Item::x
\qmlproperty real QtQuick::Item::y
\qmlproperty real QtQuick::Item::width