Skip to content
Permalink
Browse files

[GRASS] fixed new feature attributes update

  • Loading branch information
blazek committed Oct 20, 2015
1 parent f2c7522 commit 08527afac2b85db1daa1842fd67b284e753bb94d
@@ -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 )
{
@@ -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 )
@@ -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 ) );

@@ -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;
}
@@ -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

0 comments on commit 08527af

Please sign in to comment.
You can’t perform that action at this time.