Sign in to follow this  

asCModule::Build() now deletes previous scripts before compiling new?

This topic is 2050 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello there,

sorry for consuming your time once again, but I'm stuck at a strange AngelScript behaviour and I need a hint from the original author of this source to solve the issue.

I just upgraded from 2.20.3 to 2.23.1. Upgrading was done be simply copying over the new files, removing the one asm-file that seems to be gone, and adding every new source to the solution. Compiles fine, no apparent interface changes, good thing. But suddenly all but one of my scripts are not executed anymore.

I do the following for hundreds of times:

asIScriptModule::AddScriptSection( "module", someCode);
asIScriptModule::Build();

which worked fine in 2.20.3. Now in 2.23.1 most of my script executions end up with an error "function 'prepare" with 'null'" or something. I stepped through the code for some hours and I finally noticed what I think is the problem. Whenever I call Build(), the InternalReset() function at as_module.cpp:196 destroys all my previously compiled script functions before compiling the new one. I end up with three script modules, each with exactly ONE script function inside. All application-registered types, functions, methods are still there, but all but one script functions compiled at startup are gone. What do I need to do to fix this problem?

Thanks for your time!

Bye, Thomas Edited by Schrompf

Share this post


Link to post
Share on other sites
Whenever Build() is called it discards the old content and compiles the new script. [url="http://www.angelcode.com/angelscript/sdk/docs/manual/classas_i_script_module.html#a8acf107194c5f079d7f7507309ebe613"]This has always been the case[/url].

If you want a module built from multiple script sections then you should add all the script sections first and only call Build() at the end so they will be built together. Edited by Andreas Jonsson

Share this post


Link to post
Share on other sites
As much as I appreciate your work, but I have to disagree. At least in version 2.20.3 you could incrementally add script sections and build all the accumulated script code repeatedly. My software design was based on this assumption, and upto now it worked just fine.

But from your answer I learned that this was an accident, and it won't come back for good. I better get started rewriting the script system to account for this.

Share this post


Link to post
Share on other sites
What probably happened was that the script functions in previous builds were kept alive by the garbage collector or explicit references, e.g. by a live object that might call the old functions.

This is still true, i.e. even though you discard a module the compiled script is not immediately destroyed unless nobody is referencing it.

Share this post


Link to post
Share on other sites

This topic is 2050 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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