Skip to content

Commit

Permalink
Fix layer extent was not invalidated for certain geometry editing
Browse files Browse the repository at this point in the history
operations (eg move feature, add/delete/move vertex) (fix #14573)
  • Loading branch information
nyalldawson committed Mar 29, 2016
1 parent 59d4b85 commit 4ece916
Showing 1 changed file with 55 additions and 14 deletions.
69 changes: 55 additions & 14 deletions src/core/qgsvectorlayer.cpp
Expand Up @@ -1002,7 +1002,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;
}


Expand All @@ -1012,7 +1015,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 )
Expand All @@ -1021,13 +1028,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 )
Expand All @@ -1036,7 +1051,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;
}


Expand Down Expand Up @@ -1152,7 +1171,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 )
Expand All @@ -1174,7 +1197,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 )
Expand All @@ -1196,7 +1223,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 )
Expand All @@ -1205,7 +1236,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 )
Expand Down Expand Up @@ -2098,7 +2133,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;
}


Expand Down Expand Up @@ -2215,9 +2254,10 @@ bool QgsVectorLayer::deleteFeature( QgsFeatureId fid )

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

updateExtents();
updateExtents();
}

return res;
}
Expand All @@ -2230,9 +2270,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;
}
Expand Down

1 comment on commit 4ece916

@nirvn
Copy link
Contributor

@nirvn nirvn commented on 4ece916 Mar 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

Please sign in to comment.