Navigation Menu

Skip to content

Commit

Permalink
[GRASS] fixed new line attributes lost, fixes #13726
Browse files Browse the repository at this point in the history
  • Loading branch information
blazek committed Nov 1, 2015
1 parent 5f9611e commit 0ceeb51
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions src/providers/grass/qgsgrassvectormaplayer.cpp
Expand Up @@ -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;
Expand All @@ -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();
}
Expand Down

0 comments on commit 0ceeb51

Please sign in to comment.