Skip to content
Permalink
Browse files

Use unique_ptr for geometry

  • Loading branch information
m-kuhn committed Sep 10, 2018
1 parent 41184bf commit f031980f0af7ca097f586a85dbfe818b066462fb
@@ -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() )
{
@@ -73,6 +73,11 @@ QgsGeometryCheckError::QgsGeometryCheckError( const QgsGeometryCheck *check,
}
}

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

QgsRectangle QgsGeometryCheckError::affectedAreaBBox() const
{
return mGeometry->boundingBox();
@@ -125,18 +125,14 @@ class ANALYSIS_EXPORT QgsGeometryCheckError
QgsVertexId vidx = QgsVertexId(),
const QVariant &value = QVariant(),
ValueType valueType = ValueOther );
virtual ~QgsGeometryCheckError()
{
delete mGeometry;
}

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(); }
@@ -173,14 +169,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 );
@@ -199,7 +194,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;

0 comments on commit f031980

Please sign in to comment.
You can’t perform that action at this time.