Fix data races in QGeo{Path,Polygon}Private
These classes use lazy evaluation of the bounding box and clipper path.
Since these classes use implicit sharing, that could cause data races,
if the getter was called on objects in different threads that share the
same internal Private.
Fix data races by making sure that in the const getters we do the
evaluation of the cached data under a mutex. Note that non-const method
calls on an object with a shared Private are safe, as they detach before
modifying the data. Additionally, reads are confined to input variables,
which also lazy evaluation only reads, so there are no conflicts that
could lead to data races.
Also, make the cached members mutable and the relevant helper functions
const, which allows to drop const_cast<> from the calling side.
Note that this const_cast was never an UB, because it was only done
on a Private, which was never declared as const.
We now need to introduce custom copy-constructors for Private classes,
because we need to make sure that we only copy non-cached members and
do not access other's mutex-proteced fields.
Fixes: QTBUG-144952
Pick-to: 6.11 6.8
Change-Id: I7f7e9abea83e9b9c9e9254e9fab5132623931a55
Reviewed-by: Marc Mutz <marc.mutz@qt.io>