summaryrefslogtreecommitdiff
path: root/src/location/maps/qgeomappingmanagerengine.cpp
diff options
context:
space:
mode:
authorDavid Laing <david.laing@nokia.com>2011-12-05 13:17:01 +1000
committerQt by Nokia <qt-info@nokia.com>2011-12-06 00:41:24 +0100
commit3a2e52a7ca078a5bf049ed3b71966fb7a4fd5f4c (patch)
treedc9fa6503021effe7cd3c20581a67c275e39855b /src/location/maps/qgeomappingmanagerengine.cpp
parent82e1e38c7fff2c9aaced08aac54408e91e33c222 (diff)
downloadqtlocation-3a2e52a7ca078a5bf049ed3b71966fb7a4fd5f4c.tar.gz
Fix race condition in maps threading.
The mapping manager threading could was segfaulting if the thread was started and stopped before the initialization code could be run. This change takes care of that by adding a boolean which keeps track of whether the thread has been stopped Change-Id: I5cf66f9f4c31b565815044ab836604fab10c3008 Reviewed-by: Alex <alex.blasche@nokia.com>
Diffstat (limited to 'src/location/maps/qgeomappingmanagerengine.cpp')
-rw-r--r--src/location/maps/qgeomappingmanagerengine.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/location/maps/qgeomappingmanagerengine.cpp b/src/location/maps/qgeomappingmanagerengine.cpp
index d6718cdb..fc5511da 100644
--- a/src/location/maps/qgeomappingmanagerengine.cpp
+++ b/src/location/maps/qgeomappingmanagerengine.cpp
@@ -116,6 +116,8 @@ QMap<QString, QVariant> QGeoMappingManagerEngine::parameters() const
void QGeoMappingManagerEngine::init()
{
Q_D(QGeoMappingManagerEngine);
+ if (d->stopped_)
+ return;
d->initialized = true;
emit initialized();
}
@@ -124,6 +126,9 @@ void QGeoMappingManagerEngine::threadStarted()
{
Q_D(QGeoMappingManagerEngine);
+ if (d->stopped_)
+ return;
+
init();
d->timer_ = new QTimer(this);
@@ -143,6 +148,7 @@ void QGeoMappingManagerEngine::threadStarted()
void QGeoMappingManagerEngine::threadFinished()
{
Q_D(QGeoMappingManagerEngine);
+ d->stopped_ = true;
disconnect(d->timer_);
d->timer_->stop();
}
@@ -151,6 +157,9 @@ void QGeoMappingManagerEngine::requestTiles(const QList<TileSpec> &tiles)
{
Q_D(QGeoMappingManagerEngine);
+ if (d->stopped_)
+ return;
+
if (!d->started_) {
d->queue_ = tiles;
return;
@@ -176,6 +185,9 @@ void QGeoMappingManagerEngine::requestNextTile()
{
Q_D(QGeoMappingManagerEngine);
+ if (d->stopped_)
+ return;
+
TileSpec ts = d->queue_.takeFirst();
QGeoTiledMapReply *reply = getTileImage(ts);
@@ -221,6 +233,11 @@ void QGeoMappingManagerEngine::handleReply(QGeoTiledMapReply *reply, const TileS
{
Q_D(QGeoMappingManagerEngine);
+ if (d->stopped_) {
+ reply->deleteLater();
+ return;
+ }
+
if (reply->error() == QGeoTiledMapReply::NoError) {
QByteArray bytes = reply->mapImageData();
emit tileFinished(spec, bytes);
@@ -547,7 +564,8 @@ QGeoMappingManagerEnginePrivate::QGeoMappingManagerEnginePrivate()
supportsTilting(false),
minimumTilt(0.0),
maximumTilt(0.0),
- started_(false) {}
+ started_(false),
+ stopped_(false) {}
QGeoMappingManagerEnginePrivate::~QGeoMappingManagerEnginePrivate() {}