mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-16 00:03:12 -04:00
[processing] Don't throw an exception if an expression cannot
be prepared There's cases where this happens without reflecting an invalid expression. So we can try to prepare, but not abort if the preparation fails. Fixes #18103
This commit is contained in:
parent
e0b1d37cac
commit
a8110369a8
@ -123,9 +123,7 @@ class FieldsCalculator(QgisAlgorithm):
|
|||||||
if layer is not None:
|
if layer is not None:
|
||||||
exp_context.appendScope(QgsExpressionContextUtils.layerScope(layer))
|
exp_context.appendScope(QgsExpressionContextUtils.layerScope(layer))
|
||||||
|
|
||||||
if not expression.prepare(exp_context):
|
expression.prepare(exp_context)
|
||||||
raise QgsProcessingException(
|
|
||||||
self.tr('Evaluation error: {0}').format(expression.parserErrorString()))
|
|
||||||
|
|
||||||
features = source.getFeatures()
|
features = source.getFeatures()
|
||||||
total = 100.0 / source.featureCount() if source.featureCount() else 0
|
total = 100.0 / source.featureCount() if source.featureCount() else 0
|
||||||
|
@ -116,9 +116,7 @@ class RandomPointsPolygons(QgisAlgorithm):
|
|||||||
raise QgsProcessingException(expression.parserErrorString())
|
raise QgsProcessingException(expression.parserErrorString())
|
||||||
|
|
||||||
expressionContext = self.createExpressionContext(parameters, context, source)
|
expressionContext = self.createExpressionContext(parameters, context, source)
|
||||||
if not expression.prepare(expressionContext):
|
expression.prepare(expressionContext)
|
||||||
raise QgsProcessingException(
|
|
||||||
self.tr('Evaluation error: {0}').format(expression.evalErrorString()))
|
|
||||||
|
|
||||||
fields = QgsFields()
|
fields = QgsFields()
|
||||||
fields.append(QgsField('id', QVariant.Int, '', 10, 0))
|
fields.append(QgsField('id', QVariant.Int, '', 10, 0))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user