Jump to content

node_load does not behave as advertised on failure


photo

Recommended Posts

Hi,

 

We've found that when calling node_load with a node that cannot be found leads to an unrecoverable error and a crash. Obviously the absence of a node file is in most cases an unrecoverable error in any case but we'd like some graceful recovery from this problem (for error diagnosis purposes) - we have cases where we'd like to proceed operation if node loading fails. It appears if node_load fails, the object returned is not 0 as advertised in the documentation.

 

Can I suggest that node_load which currently looks like this:

 

Node node_load(string name) {

return node_cast(node_append(engine.world.loadNode(name)));

}

 

Is changed to this (or something similar):

 

Node node_load(string name) {

Node n = engine.world.loadNode(name);

if (n == 0)

return n;

 

return node_cast(node_append(n));

}

Link to comment

Description fixed, thank you. It crashes indeed. In general, it is not the best policy to return 0 and continue running, because it may lead to crashes afterwards when the node will turn out not to be valid. But you are free to customize unigine.h as you need it, there's no problem in that.

Link to comment
×
×
  • Create New...