Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Check type in QgsLayerTreeLayer::toLayer and QgsLayerTreeLayer::toGroup
  • Loading branch information
YoannQDQ authored and nyalldawson committed Apr 29, 2023
1 parent d3d8ba1 commit 5805b05
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/core/layertree/qgslayertree.h
Expand Up @@ -56,36 +56,36 @@ class CORE_EXPORT QgsLayerTree : public QgsLayerTreeGroup
}

/**
* Cast node to a group. No type checking is done - use isGroup() to find out whether this operation is legal.
* Cast node to a group.
*
* \note Not available in Python bindings, because cast is automatic.
* \since QGIS 2.4
*/
static inline QgsLayerTreeGroup *toGroup( QgsLayerTreeNode *node ) SIP_SKIP
{
return static_cast<QgsLayerTreeGroup *>( node );
return qobject_cast<QgsLayerTreeGroup *>( node );
}

/**
* Cast node to a layer. No type checking is done - use isLayer() to find out whether this operation is legal.
* Cast node to a layer.
*
* \note Not available in Python bindings, because cast is automatic.
* \since QGIS 2.4
*/
static inline QgsLayerTreeLayer *toLayer( QgsLayerTreeNode *node ) SIP_SKIP
{
return static_cast<QgsLayerTreeLayer *>( node );
return qobject_cast<QgsLayerTreeLayer *>( node );
}

/**
* Cast node to a layer. No type checking is done - use isLayer() to find out whether this operation is legal.
* Cast node to a layer.
*
* \note Not available in Python bindings, because cast is automatic.
* \since QGIS 2.4
*/
static inline const QgsLayerTreeLayer *toLayer( const QgsLayerTreeNode *node ) SIP_SKIP
{
return static_cast< const QgsLayerTreeLayer *>( node );
return qobject_cast< const QgsLayerTreeLayer *>( node );
}

/**
Expand Down

0 comments on commit 5805b05

Please sign in to comment.