realXtend / tundra

realXtend Tundra SDK, a 3D virtual world application platform.
www.realxtend.org
Apache License 2.0
84 stars 70 forks source link

OnScriptDestroyed should not be called when Tundra is exiting #673

Open Stinkfist0 opened 11 years ago

Stinkfist0 commented 11 years ago

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.

cadaver commented 11 years ago

Could also destroy all script instances (if possible) before the core objects.

jonnenauha commented 11 years ago

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

Stinkfist0 commented 11 years ago

Well, these error happens also when running scene only locally. But yes, both issues are related to application teardown in some way.

cadaver commented 11 years ago

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.