minor improvements

This commit is contained in:
Uwe Rathmann 2021-12-23 18:16:18 +01:00
parent d37b9ca39c
commit af8df9f4be
3 changed files with 20 additions and 3 deletions

View File

@ -261,10 +261,8 @@ void QskSkinlet::updateNode( QskSkinnable* skinnable, QSGNode* parentNode ) cons
replaceChildNode( DebugRole, parentNode, oldNode, newNode ); replaceChildNode( DebugRole, parentNode, oldNode, newNode );
} }
for ( int i = 0; i < m_data->nodeRoles.size(); i++ ) for ( const auto nodeRole : m_data->nodeRoles )
{ {
const auto nodeRole = m_data->nodeRoles[ i ];
Q_ASSERT( nodeRole < FirstReservedRole ); Q_ASSERT( nodeRole < FirstReservedRole );
oldNode = QskSGNode::findChildNode( parentNode, nodeRole ); oldNode = QskSGNode::findChildNode( parentNode, nodeRole );

View File

@ -69,6 +69,23 @@ static void qskInsertChildSorted( QSGNode* parent, QSGNode* child,
parent->prependChildNode( child ); parent->prependChildNode( child );
} }
void QskSGNode::setParentNode( QSGNode* node, QSGNode* parent )
{
if ( node )
{
auto oldParent = node->parent();
if ( oldParent != parent )
{
if ( oldParent )
oldParent->removeChildNode( node );
if ( parent )
parent->appendChildNode( node );
}
}
}
QSGNode* QskSGNode::findChildNode( QSGNode* parent, quint8 role ) QSGNode* QskSGNode::findChildNode( QSGNode* parent, quint8 role )
{ {
auto node = parent->firstChild(); auto node = parent->firstChild();

View File

@ -55,6 +55,8 @@ namespace QskSGNode
// including child // including child
QSK_EXPORT void removeAllChildNodesFrom( QSGNode* parent, QSGNode* child ); QSK_EXPORT void removeAllChildNodesFrom( QSGNode* parent, QSGNode* child );
QSK_EXPORT void setParentNode( QSGNode* child, QSGNode* parent );
template< typename Node > template< typename Node >
inline Node* createNode( quint8 role ) inline Node* createNode( quint8 role )
{ {