Skip to content

Commit 5c956fb

Browse files
committed
Merge pull request #216 from andrewkaufman/nonOBJ
Preventing crashes when OBJ networks contain non-OBJ nodes.
2 parents cc0e25b + 8b000ce commit 5c956fb

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/IECoreHoudini/HoudiniScene.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -675,11 +675,11 @@ void HoudiniScene::childNames( NameList &childNames ) const
675675
{
676676
for ( int i=0; i < node->getNchildren(); ++i )
677677
{
678-
OP_Node *child = node->getChild( i );
678+
OBJ_Node *child = node->getChild( i )->castToOBJNode();
679679

680680
// ignore children that have incoming connections, as those are actually grandchildren
681681
// also ignore the contentNode, which is actually an extension of ourself
682-
if ( child != contentNode && !hasInput( child ) )
682+
if ( child && child != contentNode && !hasInput( child ) )
683683
{
684684
childNames.push_back( Name( child->getName() ) );
685685
}
@@ -845,14 +845,14 @@ OP_Node *HoudiniScene::retrieveChild( const Name &name, Path &contentPath, Missi
845845
{
846846
for ( int i=0; i < node->getNchildren(); ++i )
847847
{
848-
OP_Node *child = node->getChild( i );
848+
OBJ_Node *child = node->getChild( i )->castToOBJNode();
849849
// the contentNode is actually an extension of ourself
850850
if ( child == contentNode )
851851
{
852852
continue;
853853
}
854854

855-
if ( child->getName().equal( name.c_str() ) && !hasInput( child ) )
855+
if ( child && child->getName().equal( name.c_str() ) && !hasInput( child ) )
856856
{
857857
return child;
858858
}

test/IECoreHoudini/HoudiniSceneTest.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -996,5 +996,17 @@ def testMultipleTransforms( self ) :
996996
sub3Transform = sub3Sc.readTransform( 0 ).value
997997
self.assertEqual( sub3Transform.translate, IECore.V3d( 0.0, 0.0, 0.0 ) )
998998

999+
def testIgnoreNonOBJNodes( self ) :
1000+
1001+
scene = self.buildScene()
1002+
rop = hou.node( "/obj" ).createNode( "ropnet" )
1003+
self.assertTrue( isinstance( rop, hou.RopNode ) )
1004+
# it is a child as far as Houdini is concerned
1005+
self.assertTrue( rop in scene.node().children() )
1006+
# but since its not an OBJ, we silently ignore it's existence
1007+
self.assertTrue( rop.name() not in scene.childNames() )
1008+
self.assertRaises( RuntimeError, scene.child, "ropnet" )
1009+
self.assertEqual( scene.child( "ropnet", IECore.SceneInterface.MissingBehaviour.NullIfMissing ), None )
1010+
9991011
if __name__ == "__main__":
10001012
unittest.main()

0 commit comments

Comments
 (0)