diff options
author | Ivan Solovev <ivan.solovev@qt.io> | 2022-05-25 15:33:17 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-05-30 07:58:57 +0000 |
commit | 5e91bb7a8a783777c06d8b8174bfa0b28be13934 (patch) | |
tree | 19937ba4670b3e428fde1f716732742b40d36e5f | |
parent | 1081126ae236aa3bd15ea4ce67b13447673f60ee (diff) |
Android: fix crash on exit when QGeoAreaMonitorPolling is used
QGeoAreaMonitorPolling creates a Q_GLOBAL_STATIC instance of its
QGeoAreaMonitorPollingPrivate (QGAMPP) to share the same backend among
multiple instances.
That is normally not an issue, but the QtPositioning Android backend
uses another couple of Q_GLOBAL_STATIC QMaps to keep track of the
created position or satellite info sources.
QGAMPP is trying to access these static QMaps in its destructor (when
destroying a child QGeoPositionInfoSource). But the maps may already
be destroyed at the point when QGAMPP wants to access them.
This patch fixes it by explicitly checking QGlobalStatic::exists()
before accessing the maps.
Fixes: QTBUG-103807
Pick-to: 6.3 6.2
Change-Id: I6a3c4e6c22a5ad27bf79916602a004c00e1711e1
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
-rw-r--r-- | src/plugins/position/android/src/jnipositioning.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/plugins/position/android/src/jnipositioning.cpp b/src/plugins/position/android/src/jnipositioning.cpp index fda87553..d74b17aa 100644 --- a/src/plugins/position/android/src/jnipositioning.cpp +++ b/src/plugins/position/android/src/jnipositioning.cpp @@ -195,8 +195,11 @@ namespace AndroidPositioning { void unregisterPositionInfoSource(int key) { - idToPosSource()->remove(key); - idToSatSource()->remove(key); + if (idToPosSource.exists()) + idToPosSource->remove(key); + + if (idToSatSource.exists()) + idToSatSource->remove(key); } enum PositionProvider |