Skip to content

Commit

Permalink
Move field dict generation out of loop
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed Mar 17, 2014
1 parent 1e1271f commit b38eba3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/roam/featureform.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ def setupui(self):
"""
widgetsconfig = self.formconfig['widgets']

layer = self.form.QGISLayer
# Crash in QGIS if you lookup a field that isn't found.
# We just make a dict with all fields lower because QgsFields is case sensitive.
fields = {field.name().lower():field for field in layer.pendingFields().toList()}

for config in widgetsconfig:
widgettype = config['widget']
field = config['field'].lower()
Expand All @@ -233,10 +238,6 @@ def setupui(self):
utils.warning("Not label found for {}".format(field))

widgetconfig = config.get('config', {})
layer = self.form.QGISLayer
# Crash in QGIS if you lookup a field that isn't found.
# We just make a dict with all fields lower because QgsFields is case sensitive.
fields = {field.name().lower():field for field in layer.pendingFields().toList()}
qgsfield = fields[field]
try:
widgetwrapper = WidgetsRegistry.widgetwrapper(widgettype=widgettype,
Expand Down

0 comments on commit b38eba3

Please sign in to comment.