Advertisement

asASSERT abort on delegate early destruction after Release()

Started by January 29, 2020 09:56 PM
12 comments, last by robertomurta 4 years, 9 months ago

Upgrading angelscript version indeed solved the problem of early destruction, and I was able to use delegate as function without the splitting method/object/type code.

We are still using the pre-2012 auto-wrappers version because of lots of legacy code.

the namespaces bug fixes and improvements led us to find and fix other bugs on our code. Which is great. Thank you. :D

Setting asEP_GENERIC_CALL_MODE to 0 was unecessary. :D

PS. I don't know if it's subject for another thread, but the original problem I was working on, is that: There is an object in C++ (WebsocketClient) wrapped on AS, eventually the class that instantiate it (GameScene) is destructed, and WebsocketClient should disconnect, as coded on it's C++ destructor. It works ok when passing a normal function, but when passing a delegate the destructor is not called (nor the object destructed, as it still connected).

The delegate holds a hard reference to the object, so as long as the delegate is alive it will keep the object alive.

This is one of the reasons why you may want to break up the delegate. That way you can instead hold a weak reference to the object to allow it to die even if the callback still exists.

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

Yes, that was what I thought I understood. Even with that I did some more tests and I was not expecting that behavior. Since I think this topic might be interesting for someone else, I'll open another thread explaining better.

https://www.gamedev.net/forums/topic/705642-odd-behavior-on-using-delegate-method-as-parameter-for-callback/

This topic is closed to new replies.

Advertisement