return m_subtreeGeometryCount == 0;
}
+/*!
+ \internal
+ Detaches the node from the scene graph and deletes any children it owns.
+
+ This function is called from QSGNode's and QSGRootNode's destructor. It
+ should not be called explicitly in user code. QSGRootNode needs to call
+ destroy() because destroy() calls removeChildNode() which in turn calls
+ markDirty() which type-casts the node to QSGRootNode. This type-cast is not
+ valid at the time QSGNode's destructor is called because the node will
+ already be partially destroyed at that point.
+*/
void QSGNode::destroy()
{
QSGBasicGeometryNode::~QSGBasicGeometryNode()
{
- destroy();
if (flags() & OwnsGeometry)
delete m_geometry;
}
QSGGeometryNode::~QSGGeometryNode()
{
- destroy();
if (flags() & OwnsMaterial)
delete m_material;
if (flags() & OwnsOpaqueMaterial)
QSGClipNode::~QSGClipNode()
{
- destroy();
}
QSGTransformNode::~QSGTransformNode()
{
- destroy();
}
{
while (!m_renderers.isEmpty())
m_renderers.last()->setRootNode(0);
- destroy();
+ destroy(); // Must call destroy() here because markDirty() casts this to QSGRootNode.
}
QSGOpacityNode::~QSGOpacityNode()
{
- destroy();
}
protected:
QSGNode(NodeType type);
- // When a node is destroyed, it will detach from the scene graph and the renderer will be
- // notified about the change. If the node is detached in the base node's destructor, the
- // renderer can't safely cast the node to its original type, since at this point it has been
- // partly destroyed already. To solve this problem, all the node destructors must call a common
- // destroy method.
-
- void destroy();
-
private:
+ friend class QSGRootNode;
+
void init();
+ void destroy();
QSGNode *m_parent;
NodeType m_type;
m_clear_color = color;
}
+/*!
+ Updates internal data structures and emits the sceneGraphChanged() signal.
+
+ If \a flags contains the QSGNode::DirtyNodeRemoved flag, the node might be
+ in the process of being destroyed. It is then not safe to downcast the node
+ pointer.
+*/
+
void QSGRenderer::nodeChanged(QSGNode *node, QSGNode::DirtyFlags flags)
{
Q_UNUSED(node);