Skip to content

Commit ab23779

Browse files
author
jef
committed
fix #2549
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13310 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent c71921a commit ab23779

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

src/app/attributetable/qgsattributetablemodel.cpp

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -137,23 +137,8 @@ void QgsAttributeTableModel::loadAttributes()
137137
}
138138

139139
bool ins = false, rm = false;
140-
int pendingFieldCount = mLayer->pendingFields().size();
141-
142-
if ( mFieldCount < pendingFieldCount )
143-
{
144-
ins = true;
145-
beginInsertColumns( QModelIndex(), mFieldCount, pendingFieldCount - 1 );
146-
}
147-
else if ( pendingFieldCount < mFieldCount )
148-
{
149-
rm = true;
150-
beginRemoveColumns( QModelIndex(), pendingFieldCount, mFieldCount - 1 );
151-
}
152-
153-
mFieldCount = 0;
154-
mAttributes.clear();
155-
mValueMaps.clear();
156140

141+
QgsAttributeList attributes;
157142
for ( QgsFieldMap::const_iterator it = mLayer->pendingFields().constBegin(); it != mLayer->pendingFields().end(); it++ )
158143
{
159144
switch ( mLayer->editType( it.key() ) )
@@ -169,10 +154,24 @@ void QgsAttributeTableModel::loadAttributes()
169154
break;
170155
}
171156

172-
mFieldCount++;
173-
mAttributes << it.key();
157+
attributes << it.key();
174158
}
175159

160+
if ( mFieldCount < attributes.size() )
161+
{
162+
ins = true;
163+
beginInsertColumns( QModelIndex(), mFieldCount, attributes.size() - 1 );
164+
}
165+
else if ( attributes.size() < mFieldCount )
166+
{
167+
rm = true;
168+
beginRemoveColumns( QModelIndex(), attributes.size(), mFieldCount - 1 );
169+
}
170+
171+
mFieldCount = attributes.size();
172+
mAttributes = attributes;
173+
mValueMaps.clear();
174+
176175
if ( ins )
177176
{
178177
endInsertColumns();

0 commit comments

Comments
 (0)