overte/libraries/script-engine
Anthony Thibault 6c66f5a37b Fix for DependencyManager crash on shutdown on Mac
On Mac, it is possible to crash when shutting down, it is not clear if this is due to
shutting down the app on another thread during logout or something that can happen
during normal shutdown, because it is so difficult to reproduce.

However, from looking at the stack traces it is possible for a [NSApplication terminate:]
event to get processed while Appliction::aboutToQuit() is calling ScriptEngine::waitTillDoneRunning()
This causes AppKit to invoke the static destructors too early.  Which in turn, causes the
DependencyManager destructor to fire while there are still many dependencies running.
Unfortunatly, the order of destruction is not determinstic, causing them to get shutdown
in an incorrect order.

To workaround this, we delay the call to QCoreApplication::processEvents() as late as possible,
in the Application destructor. Theoretically, this will be a safe time for the static destructors
to be invoked, because it is after all of the DependencyManager's dependencies have been
manually destroyed.

However, this is only a speculative fix, because this is so difficult to reproduce.
2019-07-01 17:37:57 -07:00
..
src Fix for DependencyManager crash on shutdown on Mac 2019-07-01 17:37:57 -07:00
CMakeLists.txt better implementation 2019-03-17 14:00:41 -07:00