Skip to content

Commit

Permalink
Fix intermittently failing postgres provider test
Browse files Browse the repository at this point in the history
Provider can crash if features do not have enough attributes
set to match fields in layer.
  • Loading branch information
nyalldawson committed Feb 26, 2018
1 parent e1a344f commit fb3e1c3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/providers/postgres/qgspostgresprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2031,7 +2031,7 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList &flist, Flags flags )
// e.g. for defaults
for ( int idx = 0; idx < attributevec.count(); ++idx )
{
QVariant v = attributevec.at( idx );
QVariant v = attributevec.value( idx, QVariant( QVariant::Int ) ); // default to NULL for missing attributes
if ( fieldId.contains( idx ) )
continue;

Expand All @@ -2050,7 +2050,7 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList &flist, Flags flags )
for ( i = 1; i < flist.size(); i++ )
{
QgsAttributes attrs2 = flist[i].attributes();
QVariant v2 = attrs2.at( idx );
QVariant v2 = attrs2.value( idx, QVariant( QVariant::Int ) ); // default to NULL for missing attributes

if ( v2 != v )
break;
Expand Down

0 comments on commit fb3e1c3

Please sign in to comment.