Skip to content

Commit 239a8d6

Browse files
committed
Fix layer extent was not invalidated for certain geometry editing
operations (eg move feature, add/delete/move vertex) (fix #14573) (cherry-picked from 4ece916)
1 parent 8c9255e commit 239a8d6

File tree

1 file changed

+55
-14
lines changed

1 file changed

+55
-14
lines changed

src/core/qgsvectorlayer.cpp

+55-14
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,10 @@ bool QgsVectorLayer::insertVertex( double x, double y, QgsFeatureId atFeatureId,
10041004
return false;
10051005

10061006
QgsVectorLayerEditUtils utils( this );
1007-
return utils.insertVertex( x, y, atFeatureId, beforeVertex );
1007+
bool result = utils.insertVertex( x, y, atFeatureId, beforeVertex );
1008+
if ( result )
1009+
updateExtents();
1010+
return result;
10081011
}
10091012

10101013

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

10161019
QgsVectorLayerEditUtils utils( this );
1017-
return utils.moveVertex( x, y, atFeatureId, atVertex );
1020+
bool result = utils.moveVertex( x, y, atFeatureId, atVertex );
1021+
1022+
if ( result )
1023+
updateExtents();
1024+
return result;
10181025
}
10191026

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

10251032
QgsVectorLayerEditUtils utils( this );
1026-
return utils.moveVertex( p, atFeatureId, atVertex );
1033+
bool result = utils.moveVertex( p, atFeatureId, atVertex );
1034+
1035+
if ( result )
1036+
updateExtents();
1037+
return result;
10271038
}
10281039

10291040
bool QgsVectorLayer::deleteVertex( QgsFeatureId atFeatureId, int atVertex )
10301041
{
10311042
QgsVectorLayer::EditResult res = deleteVertexV2( atFeatureId, atVertex );
1032-
return res == QgsVectorLayer::Success || res == QgsVectorLayer::EmptyGeometry;
1043+
bool result = ( res == QgsVectorLayer::Success || res == QgsVectorLayer::EmptyGeometry );
1044+
1045+
if ( result )
1046+
updateExtents();
1047+
return result;
10331048
}
10341049

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

10401055
QgsVectorLayerEditUtils utils( this );
1041-
return utils.deleteVertexV2( featureId, vertex );
1056+
EditResult result = utils.deleteVertexV2( featureId, vertex );
1057+
1058+
if ( result == Success )
1059+
updateExtents();
1060+
return result;
10421061
}
10431062

10441063

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

11561175
QgsVectorLayerEditUtils utils( this );
1157-
return utils.addPart( points, *mSelectedFeatureIds.constBegin() );
1176+
int result = utils.addPart( points, *mSelectedFeatureIds.constBegin() );
1177+
1178+
if ( result == 0 )
1179+
updateExtents();
1180+
return result;
11581181
}
11591182

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

11781201
QgsVectorLayerEditUtils utils( this );
1179-
return utils.addPart( points, *mSelectedFeatureIds.constBegin() );
1202+
int result = utils.addPart( points, *mSelectedFeatureIds.constBegin() );
1203+
1204+
if ( result == 0 )
1205+
updateExtents();
1206+
return result;
11801207
}
11811208

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

12001227
QgsVectorLayerEditUtils utils( this );
1201-
return utils.addPart( ring, *mSelectedFeatureIds.constBegin() );
1228+
int result = utils.addPart( ring, *mSelectedFeatureIds.constBegin() );
1229+
1230+
if ( result == 0 )
1231+
updateExtents();
1232+
return result;
12021233
}
12031234

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

12091240
QgsVectorLayerEditUtils utils( this );
1210-
return utils.translateFeature( featureId, dx, dy );
1241+
int result = utils.translateFeature( featureId, dx, dy );
1242+
1243+
if ( result == 0 )
1244+
updateExtents();
1245+
return result;
12111246
}
12121247

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

20942129
updateExtents();
20952130

2096-
return mEditBuffer->changeGeometry( fid, geom );
2131+
bool result = mEditBuffer->changeGeometry( fid, geom );
2132+
2133+
if ( result )
2134+
updateExtents();
2135+
return result;
20972136
}
20982137

20992138

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

22112250
bool res = mEditBuffer->deleteFeature( fid );
22122251
if ( res )
2252+
{
22132253
mSelectedFeatureIds.remove( fid ); // remove it from selection
2214-
2215-
updateExtents();
2254+
updateExtents();
2255+
}
22162256

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

22272267
if ( res )
2268+
{
22282269
mSelectedFeatureIds.subtract( fids ); // remove it from selection
2229-
2230-
updateExtents();
2270+
updateExtents();
2271+
}
22312272

22322273
return res;
22332274
}

0 commit comments

Comments
 (0)