Skip to content

Commit

Permalink
Merge pull request #7847 from m-kuhn/unique_ptr
Browse files Browse the repository at this point in the history
Use unique_ptr for geometry
  • Loading branch information
m-kuhn committed Sep 11, 2018
2 parents fd34cc7 + 3a1cc5a commit 0865297
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
9 changes: 7 additions & 2 deletions src/analysis/vector/geometry_checker/qgsgeometrycheck.cpp
Expand Up @@ -60,11 +60,11 @@ QgsGeometryCheckError::QgsGeometryCheckError( const QgsGeometryCheck *check,
{
if ( vidx.part != -1 )
{
mGeometry = QgsGeometryCheckerUtils::getGeomPart( layerFeature.geometry(), vidx.part )->clone();
mGeometry.reset( QgsGeometryCheckerUtils::getGeomPart( layerFeature.geometry(), vidx.part )->clone() );
}
else
{
mGeometry = layerFeature.geometry()->clone();
mGeometry.reset( layerFeature.geometry()->clone() );
}
if ( layerFeature.geometryCrs() != layerFeature.layerToMapTransform().destinationCrs().authid() )
{
Expand All @@ -73,6 +73,11 @@ QgsGeometryCheckError::QgsGeometryCheckError( const QgsGeometryCheck *check,
}
}

const QgsAbstractGeometry *QgsGeometryCheckError::geometry() const
{
return mGeometry.get();
}

QgsRectangle QgsGeometryCheckError::affectedAreaBBox() const
{
return mGeometry->boundingBox();
Expand Down
13 changes: 5 additions & 8 deletions src/analysis/vector/geometry_checker/qgsgeometrycheck.h
Expand Up @@ -125,18 +125,16 @@ class ANALYSIS_EXPORT QgsGeometryCheckError
QgsVertexId vidx = QgsVertexId(),
const QVariant &value = QVariant(),
ValueType valueType = ValueOther );
virtual ~QgsGeometryCheckError()
{
delete mGeometry;
}

virtual ~QgsGeometryCheckError() = default;

const QgsGeometryCheckError &operator=( const QgsGeometryCheckError & ) = delete;

const QgsGeometryCheck *check() const { return mCheck; }
const QString &layerId() const { return mLayerId; }
QgsFeatureId featureId() const { return mFeatureId; }
// In map units
const QgsAbstractGeometry *geometry() const { return mGeometry; }
const QgsAbstractGeometry *geometry() const;
// In map units
virtual QgsRectangle affectedAreaBBox() const;
virtual QString description() const { return mCheck->errorDescription(); }
Expand Down Expand Up @@ -173,14 +171,13 @@ class ANALYSIS_EXPORT QgsGeometryCheckError
}
virtual void update( const QgsGeometryCheckError *other )
{
delete mGeometry;
Q_ASSERT( mCheck == other->mCheck );
Q_ASSERT( mLayerId == other->mLayerId );
Q_ASSERT( mFeatureId == other->mFeatureId );
mErrorLocation = other->mErrorLocation;
mVidx = other->mVidx;
mValue = other->mValue;
mGeometry = other->mGeometry->clone();
mGeometry.reset( other->mGeometry->clone() );
}

virtual bool handleChanges( const QgsGeometryCheck::Changes &changes );
Expand All @@ -199,7 +196,7 @@ class ANALYSIS_EXPORT QgsGeometryCheckError
const QgsGeometryCheck *mCheck = nullptr;
QString mLayerId;
QgsFeatureId mFeatureId;
QgsAbstractGeometry *mGeometry;
std::unique_ptr<QgsAbstractGeometry> mGeometry;
QgsPointXY mErrorLocation;
QgsVertexId mVidx;
QVariant mValue;
Expand Down

0 comments on commit 0865297

Please sign in to comment.