Skip to content
Permalink
Browse files
[GRASS] fixed new line attributes lost, fixes #13726
(cherry picked from commit 0ceeb51)
  • Loading branch information
blazek committed Nov 1, 2015
1 parent 6dcb134 commit c38e4592f72ec62f8d230397637ce37aa7e7db19
Showing with 26 additions and 9 deletions.
  1. +26 −9 src/providers/grass/qgsgrassvectormaplayer.cpp
@@ -836,17 +836,40 @@ void QgsGrassVectorMapLayer::insertAttributes( int cat, const QgsFeature &featur
names << mFieldInfo->key;
values << QString::number( cat );

if ( feature.isValid() && feature.fields() )
QList<QVariant> cacheValues;
cacheValues.reserve( mAttributeFields.size() );
for ( int i = 0; i < mAttributeFields.size(); ++i )
{
cacheValues << QVariant();
}

if ( feature.fields() )
{
// append feature attributes if not null
for ( int i = 0; i < feature.fields()->size(); i++ )
{
QString name = feature.fields()->at( i ).name();
QVariant valueVariant = feature.attributes().value( i );

if ( name != QgsGrassVectorMap::topoSymbolFieldName() )
{
int cacheIndex = mAttributeFields.indexFromName( name );
if ( cacheIndex < 0 ) // should not happen
{
error = QString( "Field %1 not found in cached attributes" ).arg( name );
return;
}
else
{
cacheValues[cacheIndex] = valueVariant;
}
}

if ( name == mFieldInfo->key )
{
continue;
}
QVariant valueVariant = feature.attributes().value( i );

if ( !valueVariant.isNull() )
{
names << name;
@@ -860,13 +883,7 @@ void QgsGrassVectorMapLayer::insertAttributes( int cat, const QgsFeature &featur
executeSql( query, error );
if ( error.isEmpty() )
{
QList<QVariant> values;
values.reserve( mAttributeFields.size() );
for ( int i = 0; i < mAttributeFields.size(); ++i )
{
values << QVariant();
}
mAttributes[cat] = values;
mAttributes[cat] = cacheValues;
}
printCachedAttributes();
}

0 comments on commit c38e459

Please sign in to comment.