Skip to content

Commit 86e1138

Browse files
committed
[processing] Correctly handle when no feedback object is passed
1 parent ede452b commit 86e1138

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

‎python/plugins/processing/algs/qgis/Datasources2Vrt.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import xml.sax.saxutils
3232

3333
from osgeo import ogr
34-
34+
from qgis.core import QgsProcessingFeedback
3535
from processing.tools import dataobjects
3636
from processing.core.GeoAlgorithm import GeoAlgorithm
3737
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
@@ -90,6 +90,9 @@ def mergeDataSources2Vrt(self, dataSources, outFile, union=False, relative=False
9090
@param schema: Schema flag
9191
@return: vrt in string format
9292
'''
93+
if feedback is None:
94+
feedback = QgsProcessingFeedback()
95+
9396
vrt = '<OGRVRTDataSource>'
9497
if union:
9598
vrt += '<OGRVRTUnionLayer name="UnionedLayer">'

‎python/plugins/processing/core/GeoAlgorithm.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def processBeforeAddingToModeler(self, alg, model):
193193

194194
# =========================================================
195195

196-
def execute(self, feedback=QgsProcessingFeedback(), model=None):
196+
def execute(self, feedback=None, model=None):
197197
"""The method to use to call a processing algorithm.
198198
199199
Although the body of the algorithm is in processAlgorithm(),
@@ -203,6 +203,10 @@ def execute(self, feedback=QgsProcessingFeedback(), model=None):
203203
Raises a GeoAlgorithmExecutionException in case anything goes
204204
wrong.
205205
"""
206+
207+
if feedback is None:
208+
feedback = QgsProcessingFeedback()
209+
206210
self.model = model
207211
try:
208212
self.setOutputCRS()

‎python/plugins/processing/gui/AlgorithmExecutor.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,12 @@ def runalg(alg, feedback=None):
4848
Return true if everything went OK, false if the algorithm
4949
could not be completed.
5050
"""
51+
52+
if feedback is None:
53+
feedback = QgsProcessingFeedback()
54+
5155
try:
52-
alg.execute(feedback or QgsProcessingFeedback())
56+
alg.execute(feedback)
5357
return True
5458
except GeoAlgorithmExecutionException as e:
5559
ProcessingLog.addToLog(sys.exc_info()[0], ProcessingLog.LOG_ERROR)

0 commit comments

Comments
 (0)