File tree Expand file tree Collapse file tree 1 file changed +17
-18
lines changed Expand file tree Collapse file tree 1 file changed +17
-18
lines changed Original file line number Diff line number Diff line change @@ -137,23 +137,8 @@ void QgsAttributeTableModel::loadAttributes()
137
137
}
138
138
139
139
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 ();
156
140
141
+ QgsAttributeList attributes;
157
142
for ( QgsFieldMap::const_iterator it = mLayer ->pendingFields ().constBegin (); it != mLayer ->pendingFields ().end (); it++ )
158
143
{
159
144
switch ( mLayer ->editType ( it.key () ) )
@@ -169,10 +154,24 @@ void QgsAttributeTableModel::loadAttributes()
169
154
break ;
170
155
}
171
156
172
- mFieldCount ++;
173
- mAttributes << it.key ();
157
+ attributes << it.key ();
174
158
}
175
159
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
+
176
175
if ( ins )
177
176
{
178
177
endInsertColumns ();
You can’t perform that action at this time.
0 commit comments