GeoClue2 plugin: fix a crash when geoclue-2.0 is not available
The problem is similar to the one that is fixed in
03a37f36b9d967205ec70c49ad21e438df362936.
If the geoclue-2.0 package is not installed, the system does not provide
the proper D-Bus services, and the attempt to create a client fails.
The sequence that leads to a crash is as follows:
- the QDBusPendingCallWatcher instance has a reply with an error
- it is wrapped in a QScopedPointer to control its lifetime
- when handling the error, the errorOccurred() signal is emitted
- the user application (SatelliteInfo example in this case) handles
the error and decides to switch the backend
- as a result, the QGeoPositionInfoSourceGeoclue2 instance is deleted
- after the signal is processed, we return to the lambda and try to
continue the execution, which leads to destruction of the scoped
pointer. The scoped pointer tries to delete its object, but it's
already deleted -> we get a crash.
Fix it by simplifying the processing of QDBusPendingCallWatcher. We
do not actually need the scoped pointer, we can just call deleteLater()
immediately, and copy the underlying reply.
Also fix the order of the client deletion and error setting in the
other code path, because it had the same problem.
As a drive-by, fix the warning message.
Fixes: QTBUG-115933
Fixes: QTBUG-121997
Pick-to: 6.7 6.6 6.5
Change-Id: If43ddc3a132d7b26e567bcf240fdad0ebbbdbf9b
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>