Skip to content

Commit 4ece916

Browse files
committedMar 29, 2016
Fix layer extent was not invalidated for certain geometry editing
operations (eg move feature, add/delete/move vertex) (fix #14573)
1 parent 59d4b85 commit 4ece916

File tree

1 file changed

+55
-14
lines changed

1 file changed

+55
-14
lines changed
 

‎src/core/qgsvectorlayer.cpp

Lines changed: 55 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,10 @@ bool QgsVectorLayer::insertVertex( double x, double y, QgsFeatureId atFeatureId,
10021002
return false;
10031003

10041004
QgsVectorLayerEditUtils utils( this );
1005-
return utils.insertVertex( x, y, atFeatureId, beforeVertex );
1005+
bool result = utils.insertVertex( x, y, atFeatureId, beforeVertex );
1006+
if ( result )
1007+
updateExtents();
1008+
return result;
10061009
}
10071010

10081011

@@ -1012,7 +1015,11 @@ bool QgsVectorLayer::moveVertex( double x, double y, QgsFeatureId atFeatureId, i
10121015
return false;
10131016

10141017
QgsVectorLayerEditUtils utils( this );
1015-
return utils.moveVertex( x, y, atFeatureId, atVertex );
1018+
bool result = utils.moveVertex( x, y, atFeatureId, atVertex );
1019+
1020+
if ( result )
1021+
updateExtents();
1022+
return result;
10161023
}
10171024

10181025
bool QgsVectorLayer::moveVertex( const QgsPointV2& p, QgsFeatureId atFeatureId, int atVertex )
@@ -1021,13 +1028,21 @@ bool QgsVectorLayer::moveVertex( const QgsPointV2& p, QgsFeatureId atFeatureId,
10211028
return false;
10221029

10231030
QgsVectorLayerEditUtils utils( this );
1024-
return utils.moveVertex( p, atFeatureId, atVertex );
1031+
bool result = utils.moveVertex( p, atFeatureId, atVertex );
1032+
1033+
if ( result )
1034+
updateExtents();
1035+
return result;
10251036
}
10261037

10271038
bool QgsVectorLayer::deleteVertex( QgsFeatureId atFeatureId, int atVertex )
10281039
{
10291040
QgsVectorLayer::EditResult res = deleteVertexV2( atFeatureId, atVertex );
1030-
return res == QgsVectorLayer::Success || res == QgsVectorLayer::EmptyGeometry;
1041+
bool result = ( res == QgsVectorLayer::Success || res == QgsVectorLayer::EmptyGeometry );
1042+
1043+
if ( result )
1044+
updateExtents();
1045+
return result;
10311046
}
10321047

10331048
QgsVectorLayer::EditResult QgsVectorLayer::deleteVertexV2( QgsFeatureId featureId, int vertex )
@@ -1036,7 +1051,11 @@ QgsVectorLayer::EditResult QgsVectorLayer::deleteVertexV2( QgsFeatureId featureI
10361051
return QgsVectorLayer::InvalidLayer;
10371052

10381053
QgsVectorLayerEditUtils utils( this );
1039-
return utils.deleteVertexV2( featureId, vertex );
1054+
EditResult result = utils.deleteVertexV2( featureId, vertex );
1055+
1056+
if ( result == Success )
1057+
updateExtents();
1058+
return result;
10401059
}
10411060

10421061

@@ -1152,7 +1171,11 @@ int QgsVectorLayer::addPart( const QList<QgsPoint> &points )
11521171
}
11531172

11541173
QgsVectorLayerEditUtils utils( this );
1155-
return utils.addPart( points, *mSelectedFeatureIds.constBegin() );
1174+
int result = utils.addPart( points, *mSelectedFeatureIds.constBegin() );
1175+
1176+
if ( result == 0 )
1177+
updateExtents();
1178+
return result;
11561179
}
11571180

11581181
int QgsVectorLayer::addPart( const QgsPointSequenceV2 &points )
@@ -1174,7 +1197,11 @@ int QgsVectorLayer::addPart( const QgsPointSequenceV2 &points )
11741197
}
11751198

11761199
QgsVectorLayerEditUtils utils( this );
1177-
return utils.addPart( points, *mSelectedFeatureIds.constBegin() );
1200+
int result = utils.addPart( points, *mSelectedFeatureIds.constBegin() );
1201+
1202+
if ( result == 0 )
1203+
updateExtents();
1204+
return result;
11781205
}
11791206

11801207
int QgsVectorLayer::addPart( QgsCurveV2* ring )
@@ -1196,7 +1223,11 @@ int QgsVectorLayer::addPart( QgsCurveV2* ring )
11961223
}
11971224

11981225
QgsVectorLayerEditUtils utils( this );
1199-
return utils.addPart( ring, *mSelectedFeatureIds.constBegin() );
1226+
int result = utils.addPart( ring, *mSelectedFeatureIds.constBegin() );
1227+
1228+
if ( result == 0 )
1229+
updateExtents();
1230+
return result;
12001231
}
12011232

12021233
int QgsVectorLayer::translateFeature( QgsFeatureId featureId, double dx, double dy )
@@ -1205,7 +1236,11 @@ int QgsVectorLayer::translateFeature( QgsFeatureId featureId, double dx, double
12051236
return -1;
12061237

12071238
QgsVectorLayerEditUtils utils( this );
1208-
return utils.translateFeature( featureId, dx, dy );
1239+
int result = utils.translateFeature( featureId, dx, dy );
1240+
1241+
if ( result == 0 )
1242+
updateExtents();
1243+
return result;
12091244
}
12101245

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

20992134
updateExtents();
21002135

2101-
return mEditBuffer->changeGeometry( fid, geom );
2136+
bool result = mEditBuffer->changeGeometry( fid, geom );
2137+
2138+
if ( result )
2139+
updateExtents();
2140+
return result;
21022141
}
21032142

21042143

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

22162255
bool res = mEditBuffer->deleteFeature( fid );
22172256
if ( res )
2257+
{
22182258
mSelectedFeatureIds.remove( fid ); // remove it from selection
2219-
2220-
updateExtents();
2259+
updateExtents();
2260+
}
22212261

22222262
return res;
22232263
}
@@ -2230,9 +2270,10 @@ bool QgsVectorLayer::deleteFeatures( const QgsFeatureIds& fids )
22302270
bool res = mEditBuffer->deleteFeatures( fids );
22312271

22322272
if ( res )
2273+
{
22332274
mSelectedFeatureIds.subtract( fids ); // remove it from selection
2234-
2235-
updateExtents();
2275+
updateExtents();
2276+
}
22362277

22372278
return res;
22382279
}

1 commit comments

Comments
 (1)

nirvn commented on Mar 29, 2016

@nirvn
Contributor

Thanks

Please sign in to comment.