Skip to content

Commit fb3e1c3

Browse files
committedFeb 26, 2018
Fix intermittently failing postgres provider test
Provider can crash if features do not have enough attributes set to match fields in layer.
1 parent e1a344f commit fb3e1c3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
 

‎src/providers/postgres/qgspostgresprovider.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2031,7 +2031,7 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList &flist, Flags flags )
20312031
// e.g. for defaults
20322032
for ( int idx = 0; idx < attributevec.count(); ++idx )
20332033
{
2034-
QVariant v = attributevec.at( idx );
2034+
QVariant v = attributevec.value( idx, QVariant( QVariant::Int ) ); // default to NULL for missing attributes
20352035
if ( fieldId.contains( idx ) )
20362036
continue;
20372037

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

20552055
if ( v2 != v )
20562056
break;

0 commit comments

Comments
 (0)
Please sign in to comment.