[QGIS Commit] r9985 - in trunk/qgis/src: core providers/grass
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Mon Jan 19 20:11:06 EST 2009
Author: wonder
Date: 2009-01-19 20:11:06 -0500 (Mon, 19 Jan 2009)
New Revision: 9985
Modified:
trunk/qgis/src/core/qgsfeature.cpp
trunk/qgis/src/providers/grass/qgsgrassprovider.cpp
Log:
Fixed #1427 - memory leak when overwriting feature with a new feature.
Changed grass provider to avoid copying (reuse QgsFeature instance as in other providers)
Modified: trunk/qgis/src/core/qgsfeature.cpp
===================================================================
--- trunk/qgis/src/core/qgsfeature.cpp 2009-01-19 20:39:02 UTC (rev 9984)
+++ trunk/qgis/src/core/qgsfeature.cpp 2009-01-20 01:11:06 UTC (rev 9985)
@@ -61,9 +61,14 @@
mAttributes = rhs.mAttributes;
mValid = rhs.mValid;
mTypeName = rhs.mTypeName;
+
+ // make sure to delete the old geometry (if exists)
+ if (mGeometry && mOwnsGeometry)
+ delete mGeometry;
+
mGeometry = 0;
mOwnsGeometry = false;
-
+
if ( rhs.mGeometry )
setGeometry( *rhs.mGeometry );
Modified: trunk/qgis/src/providers/grass/qgsgrassprovider.cpp
===================================================================
--- trunk/qgis/src/providers/grass/qgsgrassprovider.cpp 2009-01-19 20:39:02 UTC (rev 9984)
+++ trunk/qgis/src/providers/grass/qgsgrassprovider.cpp 2009-01-20 01:11:06 UTC (rev 9985)
@@ -293,7 +293,7 @@
int cat, type, id;
unsigned char *wkb;
int wkbsize;
-
+
QgsDebugMsgLevel( "entered.", 3 );
if ( isEdited() || isFrozen() || !mValid )
@@ -318,7 +318,7 @@
QgsDebugMsg( QString( "cat = %1 type = %2 id = %3" ).arg( cat ).arg( type ).arg( id ) );
#endif
- feature = QgsFeature( id );
+ feature.setFeatureId(id);
// TODO int may be 64 bits (memcpy)
if ( type & ( GV_POINTS | GV_LINES ) ) /* points or lines */
More information about the QGIS-commit
mailing list