diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-09-14 15:28:13 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-09-20 13:41:51 +0200 |
commit | ca18c1ff0317b85b51f4ef0e888b29f083ae90a9 (patch) | |
tree | 794e442b1feb14272cf1e817d135220ccacdf9a4 | |
parent | d2ceb65c8a019204b3aa3b0b44db936ce7ce7a99 (diff) | |
download | qtlocation-ca18c1ff0317b85b51f4ef0e888b29f083ae90a9.tar.gz |
Cleanup: apply rule of zero
Remove empty destructors, use std::unique_ptr where destructors
only deleted a pointer member. This also closes the memory leak
where the tile cache was never destroyed.
Change-Id: I55007475b7f13a97d8399dd6d4234382106db05b
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
(cherry picked from commit 88018b488a26bf3657960aed75c633bc13eb7aab)
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r-- | src/location/maps/qgeocodingmanager.cpp | 16 | ||||
-rw-r--r-- | src/location/maps/qgeocodingmanager_p.h | 5 | ||||
-rw-r--r-- | src/location/maps/qgeocodingmanagerengine.cpp | 6 | ||||
-rw-r--r-- | src/location/maps/qgeocodingmanagerengine_p.h | 3 | ||||
-rw-r--r-- | src/location/maps/qgeoroutereply.cpp | 2 | ||||
-rw-r--r-- | src/location/maps/qgeoroutereply_p.h | 1 | ||||
-rw-r--r-- | src/location/maps/qgeorouterequest.cpp | 4 | ||||
-rw-r--r-- | src/location/maps/qgeorouterequest_p.h | 4 | ||||
-rw-r--r-- | src/location/maps/qgeoroutingmanager.cpp | 12 | ||||
-rw-r--r-- | src/location/maps/qgeoroutingmanager_p.h | 8 | ||||
-rw-r--r-- | src/location/maps/qgeotiledmappingmanagerengine.cpp | 6 | ||||
-rw-r--r-- | src/location/maps/qgeotiledmappingmanagerengine_p_p.h | 7 |
12 files changed, 14 insertions, 60 deletions
diff --git a/src/location/maps/qgeocodingmanager.cpp b/src/location/maps/qgeocodingmanager.cpp index 5709b869..4080bb44 100644 --- a/src/location/maps/qgeocodingmanager.cpp +++ b/src/location/maps/qgeocodingmanager.cpp @@ -84,14 +84,14 @@ QGeoCodingManager::QGeoCodingManager(QGeoCodingManagerEngine *engine, QObject *p : QObject(parent), d_ptr(new QGeoCodingManagerPrivate()) { - d_ptr->engine = engine; + d_ptr->engine.reset(engine); if (d_ptr->engine) { d_ptr->engine->setParent(this); - connect(d_ptr->engine, &QGeoCodingManagerEngine::finished, + connect(d_ptr->engine.get(), &QGeoCodingManagerEngine::finished, this, &QGeoCodingManager::finished); - connect(d_ptr->engine, &QGeoCodingManagerEngine::errorOccurred, + connect(d_ptr->engine.get(), &QGeoCodingManagerEngine::errorOccurred, this, &QGeoCodingManager::errorOccurred); } else { qFatal("The geocoding manager engine that was set for this geocoding manager was NULL."); @@ -310,14 +310,4 @@ QLocale QGeoCodingManager::locale() const /******************************************************************************* *******************************************************************************/ -QGeoCodingManagerPrivate::QGeoCodingManagerPrivate() = default; - -QGeoCodingManagerPrivate::~QGeoCodingManagerPrivate() -{ - delete engine; -} - -/******************************************************************************* -*******************************************************************************/ - QT_END_NAMESPACE diff --git a/src/location/maps/qgeocodingmanager_p.h b/src/location/maps/qgeocodingmanager_p.h index d01e5a7e..15fd38cb 100644 --- a/src/location/maps/qgeocodingmanager_p.h +++ b/src/location/maps/qgeocodingmanager_p.h @@ -62,10 +62,9 @@ class QGeoCodingManagerEngine; class QGeoCodingManagerPrivate { public: - QGeoCodingManagerPrivate(); - ~QGeoCodingManagerPrivate(); + QGeoCodingManagerPrivate() = default; - QGeoCodingManagerEngine *engine = nullptr; + std::unique_ptr<QGeoCodingManagerEngine> engine; private: Q_DISABLE_COPY(QGeoCodingManagerPrivate) diff --git a/src/location/maps/qgeocodingmanagerengine.cpp b/src/location/maps/qgeocodingmanagerengine.cpp index 8c558239..9d51c31e 100644 --- a/src/location/maps/qgeocodingmanagerengine.cpp +++ b/src/location/maps/qgeocodingmanagerengine.cpp @@ -323,10 +323,4 @@ QLocale QGeoCodingManagerEngine::locale() const signal. Use deleteLater() instead. */ -/******************************************************************************* -*******************************************************************************/ - -QGeoCodingManagerEnginePrivate::QGeoCodingManagerEnginePrivate() = default; -QGeoCodingManagerEnginePrivate::~QGeoCodingManagerEnginePrivate() = default; - QT_END_NAMESPACE diff --git a/src/location/maps/qgeocodingmanagerengine_p.h b/src/location/maps/qgeocodingmanagerengine_p.h index 065b2336..d243f851 100644 --- a/src/location/maps/qgeocodingmanagerengine_p.h +++ b/src/location/maps/qgeocodingmanagerengine_p.h @@ -60,8 +60,7 @@ QT_BEGIN_NAMESPACE class QGeoCodingManagerEnginePrivate { public: - QGeoCodingManagerEnginePrivate(); - ~QGeoCodingManagerEnginePrivate(); + QGeoCodingManagerEnginePrivate() = default; QString managerName; QLocale locale; diff --git a/src/location/maps/qgeoroutereply.cpp b/src/location/maps/qgeoroutereply.cpp index c07f62ed..33481d02 100644 --- a/src/location/maps/qgeoroutereply.cpp +++ b/src/location/maps/qgeoroutereply.cpp @@ -275,6 +275,4 @@ QGeoRouteReplyPrivate::QGeoRouteReplyPrivate(QGeoRouteReply::Error error, QStrin isFinished(true) {} -QGeoRouteReplyPrivate::~QGeoRouteReplyPrivate() {} - QT_END_NAMESPACE diff --git a/src/location/maps/qgeoroutereply_p.h b/src/location/maps/qgeoroutereply_p.h index c82e2992..ef778e5e 100644 --- a/src/location/maps/qgeoroutereply_p.h +++ b/src/location/maps/qgeoroutereply_p.h @@ -65,7 +65,6 @@ class QGeoRouteReplyPrivate public: explicit QGeoRouteReplyPrivate(const QGeoRouteRequest &request); QGeoRouteReplyPrivate(QGeoRouteReply::Error error, QString errorString); - ~QGeoRouteReplyPrivate(); QGeoRouteReply::Error error = QGeoRouteReply::NoError; QString errorString; diff --git a/src/location/maps/qgeorouterequest.cpp b/src/location/maps/qgeorouterequest.cpp index f1b2c5fa..404ed0a4 100644 --- a/src/location/maps/qgeorouterequest.cpp +++ b/src/location/maps/qgeorouterequest.cpp @@ -524,10 +524,6 @@ QVariantMap QGeoRouteRequest::extraParameters() const /******************************************************************************* *******************************************************************************/ -QGeoRouteRequestPrivate::QGeoRouteRequestPrivate() = default; -QGeoRouteRequestPrivate::QGeoRouteRequestPrivate(const QGeoRouteRequestPrivate &other) = default; -QGeoRouteRequestPrivate::~QGeoRouteRequestPrivate() = default; - bool QGeoRouteRequestPrivate::operator==(const QGeoRouteRequestPrivate &other) const { return ((waypoints == other.waypoints) diff --git a/src/location/maps/qgeorouterequest_p.h b/src/location/maps/qgeorouterequest_p.h index 23c2c924..77ddd262 100644 --- a/src/location/maps/qgeorouterequest_p.h +++ b/src/location/maps/qgeorouterequest_p.h @@ -64,10 +64,6 @@ QT_BEGIN_NAMESPACE class QGeoRouteRequestPrivate : public QSharedData { public: - QGeoRouteRequestPrivate(); - QGeoRouteRequestPrivate(const QGeoRouteRequestPrivate &other); - ~QGeoRouteRequestPrivate(); - bool operator==(const QGeoRouteRequestPrivate &other) const; QList<QGeoCoordinate> waypoints; diff --git a/src/location/maps/qgeoroutingmanager.cpp b/src/location/maps/qgeoroutingmanager.cpp index 88719edc..fb3a1d38 100644 --- a/src/location/maps/qgeoroutingmanager.cpp +++ b/src/location/maps/qgeoroutingmanager.cpp @@ -91,14 +91,14 @@ QGeoRoutingManager::QGeoRoutingManager(QGeoRoutingManagerEngine *engine, QObject : QObject(parent), d_ptr(new QGeoRoutingManagerPrivate()) { - d_ptr->engine = engine; + d_ptr->engine.reset(engine); if (d_ptr->engine) { d_ptr->engine->setParent(this); - connect(d_ptr->engine, &QGeoRoutingManagerEngine::finished, + connect(d_ptr->engine.get(), &QGeoRoutingManagerEngine::finished, this, &QGeoRoutingManager::finished); - connect(d_ptr->engine, &QGeoRoutingManagerEngine::errorOccurred, + connect(d_ptr->engine.get(), &QGeoRoutingManagerEngine::errorOccurred, this, &QGeoRoutingManager::errorOccurred); } else { qFatal("The routing manager engine that was set for this routing manager was NULL."); @@ -328,10 +328,4 @@ Use deleteLater() instead. /******************************************************************************* *******************************************************************************/ -QGeoRoutingManagerPrivate::QGeoRoutingManagerPrivate() = default; -QGeoRoutingManagerPrivate::~QGeoRoutingManagerPrivate() -{ - delete engine; -} - QT_END_NAMESPACE diff --git a/src/location/maps/qgeoroutingmanager_p.h b/src/location/maps/qgeoroutingmanager_p.h index 5dc86299..bcb9d138 100644 --- a/src/location/maps/qgeoroutingmanager_p.h +++ b/src/location/maps/qgeoroutingmanager_p.h @@ -60,13 +60,7 @@ class QGeoRoutingManagerEngine; class QGeoRoutingManagerPrivate { public: - QGeoRoutingManagerPrivate(); - ~QGeoRoutingManagerPrivate(); - - QGeoRoutingManagerEngine *engine = nullptr; - -private: - Q_DISABLE_COPY(QGeoRoutingManagerPrivate) + std::unique_ptr<QGeoRoutingManagerEngine> engine; }; QT_END_NAMESPACE diff --git a/src/location/maps/qgeotiledmappingmanagerengine.cpp b/src/location/maps/qgeotiledmappingmanagerengine.cpp index cf2bc70e..d5b24158 100644 --- a/src/location/maps/qgeotiledmappingmanagerengine.cpp +++ b/src/location/maps/qgeotiledmappingmanagerengine.cpp @@ -287,7 +287,7 @@ 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; + d->tileCache_.reset(cache); d->tileCache_->init(); } @@ -298,10 +298,10 @@ QAbstractGeoTileCache *QGeoTiledMappingManagerEngine::tileCache() QString cacheDirectory; if (!managerName().isEmpty()) cacheDirectory = QAbstractGeoTileCache::baseLocationCacheDirectory() + managerName(); - d->tileCache_ = new QGeoFileTileCache(cacheDirectory); + d->tileCache_.reset(new QGeoFileTileCache(cacheDirectory)); d->tileCache_->init(); } - return d->tileCache_; + return d->tileCache_.get(); } QSharedPointer<QGeoTileTexture> QGeoTiledMappingManagerEngine::getTileTexture(const QGeoTileSpec &spec) diff --git a/src/location/maps/qgeotiledmappingmanagerengine_p_p.h b/src/location/maps/qgeotiledmappingmanagerengine_p_p.h index aa8fc3b4..4f4f5659 100644 --- a/src/location/maps/qgeotiledmappingmanagerengine_p_p.h +++ b/src/location/maps/qgeotiledmappingmanagerengine_p_p.h @@ -67,18 +67,13 @@ class QGeoTileFetcher; class QGeoTiledMappingManagerEnginePrivate { public: - QGeoTiledMappingManagerEnginePrivate() = default; - QSize tileSize_; int m_tileVersion = -1; QHash<QGeoTiledMap *, QSet<QGeoTileSpec>> mapHash_; QHash<QGeoTileSpec, QSet<QGeoTiledMap *>> tileHash_; QAbstractGeoTileCache::CacheAreas cacheHint_ = QAbstractGeoTileCache::AllCaches; - QAbstractGeoTileCache *tileCache_ = nullptr; + std::unique_ptr<QAbstractGeoTileCache> tileCache_; QGeoTileFetcher *fetcher_ = nullptr; - -private: - Q_DISABLE_COPY(QGeoTiledMappingManagerEnginePrivate) }; QT_END_NAMESPACE |