Sign in to follow this  
Dentoid

CreateScriptObject problem

Recommended Posts

Hi I've got a problem where CreateScriptObject returns a pointer to an uninitialized piece of memory (0xcdcdcdcd in debug VC8 build). The object I'm trying to create is a script declared class with a bunch of members and methods. If I add an empty or simple constructor to the class it will instead return a null pointer. (I did a quick trace of the constructor execution inside CreateScriptObject, and on the second system call it does, the first being to some GC_AddRef or something, it gets a null pointer exception. That is, a script null ptr exception, not a system "real memory" exception.) I've got no idea what's going on... I've tried comparing to the test_scriptclassmethod test, but can't find any obvious differences, except that my class exists in a module. Don't know what more info to give, but I'll keep investigating. Just wondering if anyone (i.e. WitchLord :) has got any idea. Thanks in advance /Anders EDIT: Just FYI, I'm using the 2.6.0 release.

Share this post


Link to post
Share on other sites
Just noticed that if I change the test_scriptclassmethod example to put the script2 script in another module (and update everything that accesses it to specify that module), CreateScriptObject returns 0 too. This time, however, because the constructor context can't be prepared.

I don't understand much what's going on here. Any help is welcome. :)

/Anders

Share this post


Link to post
Share on other sites
I'll try to reproduce this problem in order to determine what's going on.

It sounds like a bug in AngelScript though.

Thanks for letting me know.

Regards,
Andreas

Share this post


Link to post
Share on other sites
I managed to reproduce the problem the way you mentioned, and I know where the problem is: The ids for the script class methods don't reflect which module they were declared in. Unfortunately this was a situation that I overlooked and the solution is not so simple.

I'll have to think about this a little and decide upon a solution.

Share this post


Link to post
Share on other sites
Ah, okay. Thanks.

You might want to think about a way then to get the module a type id resides in too, since I found no way to do that as it is now (which I guess might be related). I mean... Currently, I can't for example get the method of a class by declaration if I haven't previously stored which module the type id was found in.

Hope that made sense. :)

Share this post


Link to post
Share on other sites
Good point. :)

I seem to have overlooked quite a big part with this design. Fortunately getting the module id from the type id is easy, though it requires a new method to the engine interface.

Share this post


Link to post
Share on other sites
Sounds good :)

Don't want to push it, but is there any ETA for these fixes? They're kind of a showstopper for me. :)

Share this post


Link to post
Share on other sites
You can be assured that this is a high priority for me, as I consider it to be a bug, not a new feature. Maybe I can have a fix ready for the weekend, but I can't guarantee anything.

Share this post


Link to post
Share on other sites
Btw, do you know if there's any fairly quick hack to make it work temporarily? Like passing the module manually into CreateScriptObject or something like that? (I'm not totally sure what's going wrong. :)

Share this post


Link to post
Share on other sites
Unfortunately, the fix is slightly more complicated than that. But don't worry, I'm almost ready to release the fix. I just need to test it some more and make sure I didn't break something else in the progress.

Share this post


Link to post
Share on other sites
Having other problems now with an assert on compiling a method... I'll have to investigate more before I can give a guess on what's going on.

Share this post


Link to post
Share on other sites
Okay, I managed to reproduce the problem above in test_scriptclassmethod now. Try adding a second method that calls the first one, like this:
void method2()
{
this.method();
}

Then you'll get a compiler error that there is no method called "method" (even though there is). If you then remove both the constructor, you will instead of a compiler error hit an assert when compiling the script.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this