Open Stinkfist0 opened 11 years ago
Could also destroy all script instances (if possible) before the core objects.
I think this should be automatically solved with the TundraProtocolModule disconnect. At this point the scene should be reseted an all scripts destroyed. However the dtor disconnect is too late for a shutdown. As some modules (APIs I think persist untill modules are unloaded) might already be freed.
Imo this is related to #665
Well, these error happens also when running scene only locally. But yes, both issues are related to application teardown in some way.
The question is also, whether shutdown should be, from the perspective of scripts, same as the scene being emptied of all objects. That's naturally the internal end result anyway (as scene must be cleared before it can be properly deleted) but there could also be a separate script callback for shutdown (like OnFrameworkExit or something)
However, having a separate callback, or extra logic to suppress OnScriptDestroyed makes the code more complex. The simplest solution is a well-defined teardown order.
When Tundra Application/Framework is exiting, most of the core API pointers/dynamic objects are garbage which results in error prints in many scripts:
Error: In script destructor: Error: cannot access member IsRunning of deleted QObject
In this particular case
server
was tried to be queried.