summaryrefslogtreecommitdiff
path: root/src/location/maps/qgeomap.cpp
diff options
context:
space:
mode:
authorAlex Wilson <alex.wilson@nokia.com>2012-03-06 14:00:36 +1000
committerQt by Nokia <qt-info@nokia.com>2012-03-09 02:16:47 +0100
commit4c329881707317674e5672862f16e8143676c265 (patch)
tree0dc774424a987b01baad2969e41dcd3385055eda /src/location/maps/qgeomap.cpp
parentbb78475bef0ea9f5cb7e3cb70826e5361320f060 (diff)
downloadqtlocation-4c329881707317674e5672862f16e8143676c265.tar.gz
Implementing deregisterMap to avoid crashes on slow requests
Previously, high-latency requests that were still running could complete after deregisterMap() was called, and a pointer to the old QGeoMap would still be present in the array -- which triggered a segfault. Now we make sure to remove all references to a disappearing map. This patch also handles a common destructor race causing similar segfaults at exit (and in autotests) Change-Id: I936d6c0d556d79fc43aa238b0b1d3dc63e5db11e Reviewed-by: Aaron McCarthy <aaron.mccarthy@nokia.com>
Diffstat (limited to 'src/location/maps/qgeomap.cpp')
-rw-r--r--src/location/maps/qgeomap.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/location/maps/qgeomap.cpp b/src/location/maps/qgeomap.cpp
index 0b937f98..d4a8e2e2 100644
--- a/src/location/maps/qgeomap.cpp
+++ b/src/location/maps/qgeomap.cpp
@@ -214,7 +214,6 @@ QGeoMapPrivate::QGeoMapPrivate(QGeoMap *parent, QGeoTileCache *cache)
aspectRatio_(0.0),
map_(parent),
cache_(cache),
- manager_(0),
controller_(0),
cameraTiles_(new QGeoCameraTiles()),
mapGeometry_(new QGeoMapGeometry()),
@@ -229,7 +228,8 @@ QGeoMapPrivate::~QGeoMapPrivate()
delete mapGeometry_;
delete cameraTiles_;
- manager_->deregisterMap(map_);
+ if (manager_)
+ manager_.data()->deregisterMap(map_);
// TODO map items are not deallocated!
// However: how to ensure this is done in rendering thread?
}
@@ -241,6 +241,9 @@ QGeoTileCache* QGeoMapPrivate::tileCache()
void QGeoMapPrivate::setMappingManager(QGeoMappingManager *manager)
{
+ if (manager_)
+ manager_.data()->deregisterMap(map_);
+
if (manager) {
manager->registerMap(map_);
@@ -254,10 +257,8 @@ void QGeoMapPrivate::setMappingManager(QGeoMappingManager *manager)
mapImages_ = new QGeoMapImages(map_);
mapImages_->setMappingManager(manager);
-
- } else {
- manager->deregisterMap(map_);
}
+
manager_ = manager;
}
@@ -286,7 +287,7 @@ void QGeoMapPrivate::setCameraData(const QGeoCameraData &cameraData)
}
if (manager_) {
- QGeoCameraCapabilities capabilities = manager_->cameraCapabilities();
+ QGeoCameraCapabilities capabilities = manager_.data()->cameraCapabilities();
if (cameraData_.zoomLevel() < capabilities.minimumZoomLevel())
cameraData_.setZoomLevel(capabilities.minimumZoomLevel());
@@ -347,7 +348,7 @@ QGeoCameraData QGeoMapPrivate::cameraData() const
QGeoMappingManager *QGeoMapPrivate::manager() const
{
- return manager_;
+ return manager_.data();
}
void QGeoMapPrivate::resize(int width, int height)