Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

ScriptHandle addon doesn't check object type

$
0
0
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.

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>