Fix onBodyContact being called on removed nodes
Since collision callbacks happen in the physx simulation thread we need
to store these callbacks. Otherwise, if an object is deleted in the same
frame a 'onBodyContact' signal is enqueued and a crash will happen.
Therefore we save these contact callbacks and run them at the end of the
physics frame when we know if the objects are deleted or not.
We move the mutex in QPhysicsWorld::deregisterNode to cover also the
decoupling of the physics node since this node can be read
asynchronously in the 'onContact' physx callback.
In the 'onContact' callback we check if the node is removed _before_
dereferencing it and checking 'm_backendObject'.
Fixes: QTBUG-121033
Pick-to: 6.7 6.6 6.5
Change-Id: I2412502baa6ede1897a4d1377e8c52a8339471d2
Reviewed-by: Andy Nichols <andy.nichols@qt.io>