This fixes a bug where an entity script would be loaded but immediately
unloaded. This happens when the script property of the entity is changed shortly
after it is added.
Flow of events:
Entity added
=> Entity added event emitted
Entity edited
=> Script changing event emitted
<= Entity added event received
Script loaded
<= Script changing event received
Script stopped
Tries to load script again, but because the script hasn't changed
since it was last loaded, it is not loaded again.
The change here is to modify the behavior when receiving a script
changing event. Instead of always unloading and then conditionally
loading the script, it will either do both (unload + load) or neither.
Many render items/payloads contain smart pointers back to the
objects that added them to the scene, including entity and avatar
objects. Currently, those render items are destroyed when the
scene is destroyed very late in the application life-cycle.
There are rare crashes that can occur when these render items are
destroyed. Possibly, due to them referencing objects that have
already been destroyed via raw pointers. In an effort to
eliminate these crashes, we now destroy the scene earlier, within
Application::aboutToQuit() which is connected to the
QCoreApplication::aboutToQuit signal. Also, we guard against null
scene pointer dereferences. Any location that accesses the scene
off the main thread, now checks the validity of the scene pointer.
* Added new PointerEvent type.
* Mouse events are still sent from Application to EntityTreeRenderer, however, EntityTreeRenderer converts them to PointerEvents
* All outgoing signals from EntityTreeRenderer use PointerEvents instead of MouseEvents
* Associated JavaScript entity methods will receive PointerEvents instead of MouseEvents
* Events from handControllerGrab.js to entities are currently broken.