Skip to content

Commit 017c4d7

Browse files
author
wonder
committed
Fixed #1427 - memory leak when overwriting feature with a new feature.
Changed grass provider to avoid copying (reuse QgsFeature instance as in other providers) git-svn-id: http://svn.osgeo.org/qgis/trunk@9985 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 264062e commit 017c4d7

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/core/qgsfeature.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,14 @@ QgsFeature & QgsFeature::operator=( QgsFeature const & rhs )
6161
mAttributes = rhs.mAttributes;
6262
mValid = rhs.mValid;
6363
mTypeName = rhs.mTypeName;
64+
65+
// make sure to delete the old geometry (if exists)
66+
if (mGeometry && mOwnsGeometry)
67+
delete mGeometry;
68+
6469
mGeometry = 0;
6570
mOwnsGeometry = false;
66-
71+
6772
if ( rhs.mGeometry )
6873
setGeometry( *rhs.mGeometry );
6974

src/providers/grass/qgsgrassprovider.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ bool QgsGrassProvider::nextFeature( QgsFeature& feature )
293293
int cat, type, id;
294294
unsigned char *wkb;
295295
int wkbsize;
296-
296+
297297
QgsDebugMsgLevel( "entered.", 3 );
298298

299299
if ( isEdited() || isFrozen() || !mValid )
@@ -318,7 +318,7 @@ bool QgsGrassProvider::nextFeature( QgsFeature& feature )
318318
QgsDebugMsg( QString( "cat = %1 type = %2 id = %3" ).arg( cat ).arg( type ).arg( id ) );
319319
#endif
320320

321-
feature = QgsFeature( id );
321+
feature.setFeatureId(id);
322322

323323
// TODO int may be 64 bits (memcpy)
324324
if ( type & ( GV_POINTS | GV_LINES ) ) /* points or lines */

0 commit comments

Comments
 (0)