Skip to content

Commit

Permalink
Refactoring for possible QGIS bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
wlorenzetti committed Nov 7, 2023
1 parent 69b0636 commit 71eb4d6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions g3w-admin/qdjango/utils/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,9 +631,15 @@ def _getDataEditTypes(self):
del(options['ReferencedLayerDataSource'],
options['ReferencedLayerProviderKey'])

# Add DiplayExpression of ReferencedLayer
options['display_expression'] = self.qgisProject.qgs_project.mapLayer(
options['ReferencedLayerId']).displayExpression()
# Add DisplayExpression of ReferencedLayer
# Set it into a try except routine for a possible bug of QGIS:
# If in QGIS project is set a RelationReference form widget, if the referenced layer is changed
# the ReferencedLayerId is not changed and was the old layer id not more present into the project
try:
options['display_expression'] = self.qgisProject.qgs_project.mapLayer(
options['ReferencedLayerId']).displayExpression()
except Exception as e:
logger.debug(e)

data.update(options)
else:
Expand Down

0 comments on commit 71eb4d6

Please sign in to comment.