Skip to content

Commit

Permalink
added catch in case a renderer does not use fields
Browse files Browse the repository at this point in the history
  • Loading branch information
bogind committed Nov 21, 2024
1 parent 830fc33 commit f4c46e8
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions qlyrx_styler.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,26 +412,30 @@ def initial_lyrx_parse(self,lyrx_data,layer):
# Find a renderer with the active layer field attribute
rend_to_check = []
x = 0
for r in renderers_symb_type:
#if geometry_general_type_str in r:
rend_to_check.append(x)
x = x + 1
try:
for r in renderers_symb_type:
#if geometry_general_type_str in r:
rend_to_check.append(x)
x = x + 1

## TODO: check why unused
#rend_idx = -1
self.used_fields = []
## Check in the active layers for matching classification fields
for z in rend_to_check:
for f in renderers[z]['fields']:
if f not in self.used_fields:
self.used_fields.append(f)
field_exist = layer.fields().indexFromName(renderers[z]['fields'][0])
if field_exist > -1:
## TODO: check why unused
#rend_idx = z
pass
#for u in range(0,len(self.used_fields)):
#self.add_field_layout(dlg,layer,self.used_fields[u],u)
## TODO: check why unused
#rend_idx = -1
self.used_fields = []
## Check in the active layers for matching classification fields
for z in rend_to_check:
if 'fields' in renderers[z]:
for f in renderers[z]['fields']:
if f not in self.used_fields:
self.used_fields.append(f)
field_exist = layer.fields().indexFromName(renderers[z]['fields'][0])
if field_exist > -1:
## TODO: check why unused
#rend_idx = z
pass
#for u in range(0,len(self.used_fields)):
#self.add_field_layout(dlg,layer,self.used_fields[u],u)
except Exception as e:
QgsMessageLog.logMessage("Error parsing style {}".format(str(e)), 'qlyrxStyler', level=Qgis.MessageLevel.Critical)

def clear_field_layout(self, dlg):
fields_layout = dlg.field_selection
Expand Down

0 comments on commit f4c46e8

Please sign in to comment.