Advertisement

ScriptHandle addon doesn't check object type

Started by December 15, 2017 01:01 PM
2 comments, last by WitchLord 6 years, 11 months ago

Take the follwing example:


class Foo
{
}

class Bar : Foo
{
	void Test()
	{
		print("Test was called");
	}
}

void BugTest()
{
	ref@ x = Foo();
	Bar@ y = cast<Bar>(x);
	if (y is null)
		print("y is null, as expected");
	else
	{
		print("y is not null, calling Test() now:");
		y.Test();
	}
}

Here, the explicit cast to Bar should return null as expected, but it doesn't, because it only checks whether the types are derived from each other. Calling y.Test() can even cause a crash here.

If you explicitly cast the ref to Foo first before casting that to Bar, it will return null properly.

Thanks for the report. I'll look into this and fix the problem.

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

Advertisement

I've fixed this in revision 2454.

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

This topic is closed to new replies.

Advertisement