🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Shared class invalidates when 1 of the modules is discarded

Started by
4 comments, last by Miss 3 years, 2 months ago

I have the following shared class defined in a separate file: (as described by the documentation here: https://www.angelcode.com/angelscript/sdk/docs/manual/doc_script_shared.html)

shared class Foo
{
	void MethodInFoo(int b) { bar = b; }
	int bar;
}

Then I have 2 modules that include this file:

#include "SharedStuff.as"

void Main()
{
	Foo@ f = Foo();
}
#include "SharedStuff.as"

void Main()
{
}

When both modules are loaded, everything works as expected - the class is shared and can be passed between modules as expected.

However, when the first module gets discarded and a new module gets created (with the same script), the class seems to suddenly become invalid, giving the following error on the Foo instantiation line:

INFO : Compiling void Main()
 ERR : Can't implicitly convert from 'void' to 'Foo@&'.

If I discard the 2nd module and then do the same thing (discard 1st and reload it) then it works as expected again.

Is there some kind of refcounting going wrong on the shared class when 2 modules are using it?

Advertisement

Similarly, I get a failed assertion here:

void asCContext::CallScriptFunction(asCScriptFunction *func)
{
	asASSERT( func->scriptData );

If I change the 2nd module script to this:

void Main()
{
	while (true) {
		Foo@ f = Foo();
		yield();
	}
}

And discard the first module.

I don't have any experience with shared entities and imported functions yet, so maybe I'm just misunderstanding some of the concepts.

Looks like you've hit a bug in angelscript. The shared class should survive when you discard the module that declared it, as long as there are other modules using it.

I have several test cases for this in the regression test suite. What might be specific in your case (and hasn't been tested) is that the second module is just declaring the shared class but not actually using it.

I'll look into these problems and get back to you as soon as possible.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

I've fixed this in rev 2727.

Regards,
Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Awesome, thank you!

This topic is closed to new replies.

Advertisement