diff options
author | Ivan Solovev <ivan.solovev@qt.io> | 2021-05-12 16:58:09 +0200 |
---|---|---|
committer | Ivan Solovev <ivan.solovev@qt.io> | 2021-05-20 13:06:24 +0200 |
commit | 6cc553b1579f6448e2a2734bbb4348e30b6ff09e (patch) | |
tree | 58e67ac210ef9ac8372d951e9b9c2f172f6e21ac /tests/auto/qgeoareamonitor/logfilepositionsource.h | |
parent | 668fb8be4396b944e6b0425f8ccbb5e284944c34 (diff) | |
download | qtlocation-6cc553b1579f6448e2a2734bbb4348e30b6ff09e.tar.gz |
QGeoAreaMonitorPolling: fix connection check logic
QGeoAreaMonitorPolling class overrides QObject::connectNotify() and
QObject::disconnectNotify() to check, if it has any connected objects
and decide, if it needs to start/stop position monitoring.
Previously it used QObject::isSignalConnected() to perform the check.
However this method locks a QObject's mutex, so it's not safe to call
it from QObject::disconnectNotify(), because the latter is called
from a QObject's destructor, which is also locking a QObject's mutex.
Both locks use signalSlotLock static method from qobject.cpp to
determine, which mutex to lock. The selection is made based on the
object's address. At some rare case this can lead to selecting the
same mutex. And as a result we get a deadlock, when trying to lock
the same mutex for the second time.
This patch updates the logic of the overridden methods in
QGeoAreaMonitorPolling. They do not use the
QObject::isSignalConnected() method, but implement a custom solution
to track the number of connections. This solution requires
synchronization, because connectNotify() and disconnectNotify() can
be triggered from different threads.
Fixes: QTBUG-93420
Fixes: QTBUG-91434
Change-Id: I45ba03e238edc136f1bb42ca6b11a528ab5c22e8
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'tests/auto/qgeoareamonitor/logfilepositionsource.h')
-rw-r--r-- | tests/auto/qgeoareamonitor/logfilepositionsource.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/auto/qgeoareamonitor/logfilepositionsource.h b/tests/auto/qgeoareamonitor/logfilepositionsource.h index 5d21b17a..b175f7e9 100644 --- a/tests/auto/qgeoareamonitor/logfilepositionsource.h +++ b/tests/auto/qgeoareamonitor/logfilepositionsource.h @@ -53,6 +53,11 @@ public: int minimumUpdateInterval() const override; Error error() const override; +signals: + void noDataLeft(); + void updatesStarted(); + void updatesStopped(); + public slots: virtual void startUpdates() override; virtual void stopUpdates() override; @@ -70,6 +75,7 @@ private: Error lastError = QGeoPositionInfoSource::NoError; const QList<QByteArray> &lines; qsizetype index = -1; + bool noDataEmitted = false; }; #endif |