summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@theqtcompany.com>2016-07-17 18:10:05 +0200
committerPaolo Angelelli <paolo.angelelli@theqtcompany.com>2016-07-18 09:57:19 +0000
commitccaaa0f9d0268142f3678476655562cb5eb1dfef (patch)
tree441a512bd710c7255717d9d08278622f9ef5f767
parent24ecdc6c962ff40096782bffc24b7d6623c4a87e (diff)
downloadqtlocation-ccaaa0f9d0268142f3678476655562cb5eb1dfef.tar.gz
Fix potential memory leak in QGeoTiledMappingManagerEngine
Currently setTileFetcher and setTileCache behave in two different ways, while the former relies on having the parent set properly for the destruction, the latter is deleted on destruction With this patch handles both pointers are handled in the same way: they are parented in the setter, and the destruction is left to the qobject destructor. Change-Id: Iaf11a12cd95088fd2268817b39fb9d58311b1812 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
-rw-r--r--src/location/maps/qgeotiledmappingmanagerengine.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/location/maps/qgeotiledmappingmanagerengine.cpp b/src/location/maps/qgeotiledmappingmanagerengine.cpp
index 4e777ab2..dc5f1889 100644
--- a/src/location/maps/qgeotiledmappingmanagerengine.cpp
+++ b/src/location/maps/qgeotiledmappingmanagerengine.cpp
@@ -65,11 +65,16 @@ QGeoTiledMappingManagerEngine::~QGeoTiledMappingManagerEngine()
delete d_ptr;
}
-
+/*!
+ Sets the tile fetcher. Takes ownership of the QObject.
+*/
void QGeoTiledMappingManagerEngine::setTileFetcher(QGeoTileFetcher *fetcher)
{
Q_D(QGeoTiledMappingManagerEngine);
+ if (d->fetcher_)
+ d->fetcher_->deleteLater();
+ fetcher->setParent(this);
d->fetcher_ = fetcher;
qRegisterMetaType<QGeoTileSpec>();
@@ -275,10 +280,14 @@ void QGeoTiledMappingManagerEngine::setCacheHint(QGeoTiledMappingManagerEngine::
d->cacheHint_ = cacheHint;
}
+/*!
+ Sets the tile cache. Takes ownership of the QObject.
+*/
void QGeoTiledMappingManagerEngine::setTileCache(QAbstractGeoTileCache *cache)
{
Q_D(QGeoTiledMappingManagerEngine);
Q_ASSERT_X(!d->tileCache_, Q_FUNC_INFO, "This should be called only once");
+ cache->setParent(this);
d->tileCache_ = cache;
}
@@ -312,7 +321,6 @@ QGeoTiledMappingManagerEnginePrivate::QGeoTiledMappingManagerEnginePrivate()
QGeoTiledMappingManagerEnginePrivate::~QGeoTiledMappingManagerEnginePrivate()
{
- delete tileCache_;
}
#include "moc_qgeotiledmappingmanagerengine_p.cpp"