Showing with 16 additions and 2 deletions.
  1. +2 −0 python/core/qgsfeature.sip
  2. +2 −2 src/app/qgsmaptooladdfeature.cpp
  3. +10 −0 src/core/qgsfeature.cpp
  4. +2 −0 src/core/qgsfeature.h
2 changes: 2 additions & 0 deletions python/core/qgsfeature.sip
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ class QgsFeature
//! Constructor
QgsFeature( qint64 id = 0 );

QgsFeature( const QgsFields& fields, qint64 id = 0 );

/** copy ctor needed due to internal pointer */
QgsFeature( const QgsFeature & rhs );

Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsmaptooladdfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void QgsMapToolAddFeature::canvasReleaseEvent( QMouseEvent * e )
//grass provider has its own mechanism of feature addition
if ( provider->capabilities() & QgsVectorDataProvider::AddFeatures )
{
QgsFeature* f = new QgsFeature( 0 );
QgsFeature* f = new QgsFeature( vlayer->pendingFields(), 0 );

QgsGeometry *g = 0;
if ( layerWKBType == QGis::WKBPoint || layerWKBType == QGis::WKBPoint25D )
Expand Down Expand Up @@ -198,7 +198,7 @@ void QgsMapToolAddFeature::canvasReleaseEvent( QMouseEvent * e )
}

//create QgsFeature with wkb representation
QgsFeature* f = new QgsFeature( 0 );
QgsFeature* f = new QgsFeature( vlayer->pendingFields(), 0 );

QgsGeometry *g;

Expand Down
10 changes: 10 additions & 0 deletions src/core/qgsfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ QgsFeature::QgsFeature( QgsFeatureId id )
// NOOP
}

QgsFeature::QgsFeature( const QgsFields &fields, QgsFeatureId id )
: mFid( id )
, mGeometry( 0 )
, mOwnsGeometry( 0 )
, mValid( false )
, mFields( &fields )
{
initAttributes( fields.count() );
}

QgsFeature::QgsFeature( QgsFeature const & rhs )
: mFid( rhs.mFid )
, mAttributes( rhs.mAttributes )
Expand Down
2 changes: 2 additions & 0 deletions src/core/qgsfeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ class CORE_EXPORT QgsFeature
//! Constructor
QgsFeature( QgsFeatureId id = QgsFeatureId() );

QgsFeature( const QgsFields& fields, QgsFeatureId id = QgsFeatureId() );

/** copy ctor needed due to internal pointer */
QgsFeature( const QgsFeature & rhs );

Expand Down