Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[processing] Use silent feedback by default in processing.run
Relying on the iface messagebar feedback as a fallback is not
safe for standalone scripts. If callers want to use a message
bar feedback they should specify this feedback object specifically
when calling processing.run
  • Loading branch information
nyalldawson committed Apr 10, 2018
1 parent bf0c4f9 commit d5573a5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion python/plugins/processing/core/Processing.py
Expand Up @@ -116,7 +116,7 @@ def runAlgorithm(algOrName, parameters, onFinish=None, feedback=None, context=No
alg = QgsApplication.processingRegistry().createAlgorithmById(algOrName)

if feedback is None:
feedback = MessageBarProgress(alg.displayName() if alg else Processing.tr('Processing'))
feedback = QgsProcessingFeedback()

if alg is None:
# fix_print_with_import
Expand Down

1 comment on commit d5573a5

@MathieuChailloux
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the import missing ?

I've got name 'QgsProcessingFeedback' is not defined when my plugin calls r.cost through processing.run.
The error disappears when importing QgsProcessingFeedback.

Here is the full stacktrace

Traceback (most recent call last):
  File "C:/Users/mathieu.chailloux/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ecologicalcontinuity\eco_cont_dialog.py", line 83, in runCost
    raise e
  File "C:/Users/mathieu.chailloux/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ecologicalcontinuity\eco_cont_dialog.py", line 79, in runCost
    processing.run("grass7:r.cost",parameters)
  File "C:/TMP_OS\~1/apps/qgis-dev/./python/plugins\processing\tools\general.py", line 84, in run
    return Processing.runAlgorithm(algOrName, parameters, onFinish, feedback, context)
  File "C:/TMP_OS\~1/apps/qgis-dev/./python/plugins\processing\core\Processing.py", line 119, in runAlgorithm
    feedback = QgsProcessingFeedback()
NameError: name 'QgsProcessingFeedback' is not defined

Best regards,
Mathieu

Please sign in to comment.