Skip to content

Commit 08527af

Browse files
committed
[GRASS] fixed new feature attributes update
1 parent f2c7522 commit 08527af

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/providers/grass/qgsgrassprovider.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,8 @@ void QgsGrassProvider::onFeatureAdded( QgsFeatureId fid )
12581258
// resetting fid probably is not possible because it is stored in undo commands and used in buffer maps
12591259

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

13001301
// There may be other new features with the same cat which we have to update
1301-
QgsFeatureMap& addedFeatures = const_cast<QgsFeatureMap&>( mEditBuffer->addedFeatures() );
13021302
Q_FOREACH ( QgsFeatureId addedFid, addedFeatures.keys() )
13031303
{
13041304
if ( addedFid == fid )

src/providers/grass/qgsgrassvectormaplayer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@ void QgsGrassVectorMapLayer::reinsertAttributes( int cat, QString &error )
902902
}
903903
}
904904

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

@@ -936,7 +936,7 @@ void QgsGrassVectorMapLayer::updateAttributes( int cat, const QgsFeature &featur
936936
// update feature null values by existing values
937937
if ( cacheIndex != -1 )
938938
{
939-
feature.attributes()[i] = mAttributes[cat][cacheIndex];
939+
feature.setAttribute( i, mAttributes[cat][cacheIndex] );
940940
}
941941
continue;
942942
}

src/providers/grass/qgsgrassvectormaplayer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class GRASS_LIB_EXPORT QgsGrassVectorMapLayer : public QObject
120120
* @param cat
121121
* @param nullValues override all values, if false, only non empty values are used for update
122122
*/
123-
void updateAttributes( int cat, const QgsFeature &feature, QString &error, bool nullValues = false );
123+
void updateAttributes( int cat, QgsFeature &feature, QString &error, bool nullValues = false );
124124

125125
/** Delete attributes from the table
126126
* @param cat

0 commit comments

Comments
 (0)