Skip to content

Commit

Permalink
Followup 1bdef80: Fix crash when layer not in edit mode
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Aug 27, 2014
1 parent 1bdef80 commit b3d19d6
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/core/qgsvectorlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2821,22 +2821,25 @@ void QgsVectorLayer::uniqueValues( int index, QList<QVariant> &uniqueValues, int
{
mDataProvider->uniqueValues( index, uniqueValues, limit );

QSet<QString> vals;
Q_FOREACH( const QVariant& v, uniqueValues )
vals << v.toString();

QMapIterator< QgsFeatureId, QgsAttributeMap > it ( mEditBuffer->changedAttributeValues() );
while ( it.hasNext() && ( limit < 0 || uniqueValues.count() < limit ) )
if ( mEditBuffer )
{
it.next();
QVariant v = it.value().value( index );
if ( v.isValid() )
QSet<QString> vals;
Q_FOREACH( const QVariant& v, uniqueValues )
vals << v.toString();

QMapIterator< QgsFeatureId, QgsAttributeMap > it ( mEditBuffer->changedAttributeValues() );
while ( it.hasNext() && ( limit < 0 || uniqueValues.count() < limit ) )
{
QString vs = v.toString();
if ( !vals.contains( vs ) )
it.next();
QVariant v = it.value().value( index );
if ( v.isValid() )
{
vals << vs;
uniqueValues << v;
QString vs = v.toString();
if ( !vals.contains( vs ) )
{
vals << vs;
uniqueValues << v;
}
}
}
}
Expand Down

0 comments on commit b3d19d6

Please sign in to comment.