While I've found a way to init correctly the scripting, I think
there is a bug in the code that we might need to fix.
When you set the system interface, you pass in the argv and argc and
the interface keeps a pointer to them. Then, when you init the
script system, the code calls the InitializeAllWrappers method. That
function, toward its end, has this call:
context->Global()->Set(String::New("CmdLineArgs"),
WrapCmdLineArgs());
This is where we might have a problem; WrapCmdLineArgs uses:
for(int i = 0; i < argc; ++i)
{
const char* arg = argv[i];
o->Set(i, String::New(arg));
}
Now, the argument list is most probably also used by the app via an
osg::ArgumentParser; this guy, when reading values from it, removes
entries. As a result, you may arrive in WrapCmdLineArgs with less
arguments that you had originally. So the loop on argc will go over
bad pointers and this causes crashes. I've just been able to
reproduce it so the issue is really there.
Not too sure how this could be fixed (I don't know the wrapper stuff
well enough) but for sure this might cause troubles to people, like
it did to me, so it's worth finding a solution I think.
Hope it helps.
Luca