Skip to content
Permalink
Browse files

Fix layer extent was not invalidated for certain geometry editing

operations (eg move feature, add/delete/move vertex) (fix #14573)

(cherry-picked from 4ece916)
  • Loading branch information
nyalldawson committed Apr 4, 2016
1 parent 8c9255e commit 239a8d60ae1dc2ece362b3df9d9977a1379abd97
Showing with 55 additions and 14 deletions.
  1. +55 −14 src/core/qgsvectorlayer.cpp
@@ -1004,7 +1004,10 @@ bool QgsVectorLayer::insertVertex( double x, double y, QgsFeatureId atFeatureId,
return false;

QgsVectorLayerEditUtils utils( this );
return utils.insertVertex( x, y, atFeatureId, beforeVertex );
bool result = utils.insertVertex( x, y, atFeatureId, beforeVertex );
if ( result )
updateExtents();
return result;
}


@@ -1014,7 +1017,11 @@ bool QgsVectorLayer::moveVertex( double x, double y, QgsFeatureId atFeatureId, i
return false;

QgsVectorLayerEditUtils utils( this );
return utils.moveVertex( x, y, atFeatureId, atVertex );
bool result = utils.moveVertex( x, y, atFeatureId, atVertex );

if ( result )
updateExtents();
return result;
}

bool QgsVectorLayer::moveVertex( const QgsPointV2& p, QgsFeatureId atFeatureId, int atVertex )
@@ -1023,13 +1030,21 @@ bool QgsVectorLayer::moveVertex( const QgsPointV2& p, QgsFeatureId atFeatureId,
return false;

QgsVectorLayerEditUtils utils( this );
return utils.moveVertex( p, atFeatureId, atVertex );
bool result = utils.moveVertex( p, atFeatureId, atVertex );

if ( result )
updateExtents();
return result;
}

bool QgsVectorLayer::deleteVertex( QgsFeatureId atFeatureId, int atVertex )
{
QgsVectorLayer::EditResult res = deleteVertexV2( atFeatureId, atVertex );
return res == QgsVectorLayer::Success || res == QgsVectorLayer::EmptyGeometry;
bool result = ( res == QgsVectorLayer::Success || res == QgsVectorLayer::EmptyGeometry );

if ( result )
updateExtents();
return result;
}

QgsVectorLayer::EditResult QgsVectorLayer::deleteVertexV2( QgsFeatureId featureId, int vertex )
@@ -1038,7 +1053,11 @@ QgsVectorLayer::EditResult QgsVectorLayer::deleteVertexV2( QgsFeatureId featureI
return QgsVectorLayer::InvalidLayer;

QgsVectorLayerEditUtils utils( this );
return utils.deleteVertexV2( featureId, vertex );
EditResult result = utils.deleteVertexV2( featureId, vertex );

if ( result == Success )
updateExtents();
return result;
}


@@ -1154,7 +1173,11 @@ int QgsVectorLayer::addPart( const QList<QgsPoint> &points )
}

QgsVectorLayerEditUtils utils( this );
return utils.addPart( points, *mSelectedFeatureIds.constBegin() );
int result = utils.addPart( points, *mSelectedFeatureIds.constBegin() );

if ( result == 0 )
updateExtents();
return result;
}

int QgsVectorLayer::addPart( const QgsPointSequenceV2 &points )
@@ -1176,7 +1199,11 @@ int QgsVectorLayer::addPart( const QgsPointSequenceV2 &points )
}

QgsVectorLayerEditUtils utils( this );
return utils.addPart( points, *mSelectedFeatureIds.constBegin() );
int result = utils.addPart( points, *mSelectedFeatureIds.constBegin() );

if ( result == 0 )
updateExtents();
return result;
}

int QgsVectorLayer::addPart( QgsCurveV2* ring )
@@ -1198,7 +1225,11 @@ int QgsVectorLayer::addPart( QgsCurveV2* ring )
}

QgsVectorLayerEditUtils utils( this );
return utils.addPart( ring, *mSelectedFeatureIds.constBegin() );
int result = utils.addPart( ring, *mSelectedFeatureIds.constBegin() );

if ( result == 0 )
updateExtents();
return result;
}

int QgsVectorLayer::translateFeature( QgsFeatureId featureId, double dx, double dy )
@@ -1207,7 +1238,11 @@ int QgsVectorLayer::translateFeature( QgsFeatureId featureId, double dx, double
return -1;

QgsVectorLayerEditUtils utils( this );
return utils.translateFeature( featureId, dx, dy );
int result = utils.translateFeature( featureId, dx, dy );

if ( result == 0 )
updateExtents();
return result;
}

int QgsVectorLayer::splitParts( const QList<QgsPoint>& splitLine, bool topologicalEditing )
@@ -2093,7 +2128,11 @@ bool QgsVectorLayer::changeGeometry( QgsFeatureId fid, QgsGeometry* geom )

updateExtents();

return mEditBuffer->changeGeometry( fid, geom );
bool result = mEditBuffer->changeGeometry( fid, geom );

if ( result )
updateExtents();
return result;
}


@@ -2210,9 +2249,10 @@ bool QgsVectorLayer::deleteFeature( QgsFeatureId fid )

bool res = mEditBuffer->deleteFeature( fid );
if ( res )
{
mSelectedFeatureIds.remove( fid ); // remove it from selection

updateExtents();
updateExtents();
}

return res;
}
@@ -2225,9 +2265,10 @@ bool QgsVectorLayer::deleteFeatures( const QgsFeatureIds& fids )
bool res = mEditBuffer->deleteFeatures( fids );

if ( res )
{
mSelectedFeatureIds.subtract( fids ); // remove it from selection

updateExtents();
updateExtents();
}

return res;
}

0 comments on commit 239a8d6

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