Skip to content

Commit

Permalink
[GRASS] fixed new feature attributes update
Browse files Browse the repository at this point in the history
  • Loading branch information
blazek committed Oct 20, 2015
1 parent f2c7522 commit 08527af
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/providers/grass/qgsgrassprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,8 @@ void QgsGrassProvider::onFeatureAdded( QgsFeatureId fid )
// resetting fid probably is not possible because it is stored in undo commands and used in buffer maps

// It may be that user manualy entered cat value
const QgsFeature &feature = mEditBuffer->addedFeatures()[fid];
QgsFeatureMap& addedFeatures = const_cast<QgsFeatureMap&>( mEditBuffer->addedFeatures() );
QgsFeature& feature = addedFeatures[fid];
int catIndex = feature.fields()->indexFromName( mLayer->keyColumnName() );
if ( catIndex != -1 )
{
Expand Down Expand Up @@ -1298,7 +1299,6 @@ void QgsGrassProvider::onFeatureAdded( QgsFeatureId fid )
mLayer->updateAttributes( newCat, feature, error ); // also updates feature by existing non null attributes

// There may be other new features with the same cat which we have to update
QgsFeatureMap& addedFeatures = const_cast<QgsFeatureMap&>( mEditBuffer->addedFeatures() );
Q_FOREACH ( QgsFeatureId addedFid, addedFeatures.keys() )
{
if ( addedFid == fid )
Expand Down
4 changes: 2 additions & 2 deletions src/providers/grass/qgsgrassvectormaplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ void QgsGrassVectorMapLayer::reinsertAttributes( int cat, QString &error )
}
}

void QgsGrassVectorMapLayer::updateAttributes( int cat, const QgsFeature &feature, QString &error, bool nullValues )
void QgsGrassVectorMapLayer::updateAttributes( int cat, QgsFeature &feature, QString &error, bool nullValues )
{
QgsDebugMsg( QString( "mField = %1 cat = %2" ).arg( mField ).arg( cat ) );

Expand Down Expand Up @@ -936,7 +936,7 @@ void QgsGrassVectorMapLayer::updateAttributes( int cat, const QgsFeature &featur
// update feature null values by existing values
if ( cacheIndex != -1 )
{
feature.attributes()[i] = mAttributes[cat][cacheIndex];
feature.setAttribute( i, mAttributes[cat][cacheIndex] );
}
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/providers/grass/qgsgrassvectormaplayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class GRASS_LIB_EXPORT QgsGrassVectorMapLayer : public QObject
* @param cat
* @param nullValues override all values, if false, only non empty values are used for update
*/
void updateAttributes( int cat, const QgsFeature &feature, QString &error, bool nullValues = false );
void updateAttributes( int cat, QgsFeature &feature, QString &error, bool nullValues = false );

/** Delete attributes from the table
* @param cat
Expand Down

0 comments on commit 08527af

Please sign in to comment.