EXC_BAD_ACCESS on h3dAddGroupNode
Page 1 of 1

Author:  MistaED [ 26.04.2011, 10:01 ]
Post subject:  EXC_BAD_ACCESS on h3dAddGroupNode

Hi all,

When I make a call to h3dAddGroupNode when I want to make an "Anchor" node for my camera to pivot around, eg.
_anchor = h3dAddGroupNode( H3DRootNode, "Anchor" );

(Where _anchor is just a H3DNode member in my class) I get an EXC_BAD_ACCESS while I'm porting to iOS. Afaik this is due to accessing an object which doesn't exist or has been removed from the stack or an object access which isn't expected, some confusing stuff for a novice C++ programmer like me :) but it seems to only affect iOS as my port to the N900 didn't encounter any issues like this. Also a call to h3dAddCameraNode doesn't seem to have any issues. The exact offending call is here in egMain.cpp:
DLLEXP NodeHandle h3dAddGroupNode( NodeHandle parent, const char *name )
   SceneNode *parentNode = Modules::sceneMan().resolveNodeHandle( parent );
   APIFUNC_VALIDATE_NODE( parentNode, "h3dAddGroupNode", 0 );

   //Modules::log().writeInfo( "Adding Group node '%s'", safeStr( name ).c_str() );
   GroupNodeTpl tpl( safeStr( name, 0 ) );
   SceneNode *sn = Modules::sceneMan().findType( SceneNodeTypes::Group )->factoryFunc( tpl ); //<-- this call right here gives off an EXC_BAD_ACCESS
   return Modules::sceneMan().addNode( sn, *parentNode );

My naive problem solving tells me it is because of the casting from a SceneNodeTpl to a GroupNodeTpl on a const? In here:
SceneNode *GroupNode::factoryFunc( const SceneNodeTpl &nodeTpl )
   if( nodeTpl.type != SceneNodeTypes::Group ) return 0x0;
   return new GroupNode( *(GroupNodeTpl *)&nodeTpl ); //<-- right here

This might be just specific for iOS but I think it might be an issue in the long run for the desktop builds, I'm curious now if the OS X port has this issue when adding a group node... If this is a trivial problem on my part I apologise but I thought I might as well post about it, thanks!

Author:  marciano [ 28.05.2011, 10:22 ]
Post subject:  Re: EXC_BAD_ACCESS on h3dAddGroupNode

Sorry MistaED, this topic stayed under our radar.

Could it be that findType is returning NULL in that case?

Author:  MistaED [ 30.05.2011, 00:21 ]
Post subject:  Re: EXC_BAD_ACCESS on h3dAddGroupNode

Not a problem marciano :)

Xcode is a little funny for iOS, partial recompiles are completely unreliable so compiling from scratch for every change seems to aleviate the issue, plus I need to take into account the app lifecycles and their pseudo multitasking I think...

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group