Followup 1bdef80: Fix crash when layer not in edit mode

This commit is contained in:
Matthias Kuhn 2014-08-27 15:55:01 +02:00
parent 1bdef80ef4
commit b3d19d6b65

View File

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