initializing the scripting system

7 views
Skip to first unread message

Luca Vezzadini

unread,
Feb 6, 2013, 5:43:16 AM2/6/13
to dtEntity developers
Me again...

I need to understand what is the clean, correct way to initialize scripting. I see for example that sometimes you use the macro USE_DTENTITYPLUGIN(dtEntityV8Plugin), while in other cases you explicitely call AddPlugin on the plugin manager.

Right now I have a scene that uses a scripts and it loads fine in the editor (the script gets triggered). The same scene in my code gives this error:
   File: tEntity\rapidxmlmapencoder.cpp Line: 695 Message: In scene Scenes/Maintenance.dtescene: Cannot setup entity system. Component type not found: Script

Looks like the plugin is not initialized as it should but all the solutions I've tried seem to fail. Note that the AddPlugin is executed OK so the DLL is actually loaded...

Thanks.

   luca
--
_______________________________________________________________________
Luca Vezzadini R&D Team
Kairos3D Srl www.kairos3d.it

Martin Scheffler

unread,
Feb 6, 2013, 6:14:50 AM2/6/13
to dtenti...@googlegroups.com
Hmm, probably the V8 plugin is not found in the plugin path. All plugins in plugin path are loaded. Try dtEntityScript --pluginPath pluginlocation


2013/2/6 Luca Vezzadini <luca.ve...@kairos3d.it>

--
You received this message because you are subscribed to the Google Groups "dtEntity developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dtentity-dev...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Luca Vezzadini

unread,
Feb 6, 2013, 8:26:28 AM2/6/13
to dtEntity developers
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
Reply all
Reply to author
Forward
0 new messages