Skip to content
Permalink
Browse files

[processing] Correctly handle when no feedback object is passed

  • Loading branch information
nyalldawson committed Jan 11, 2017
1 parent ede452b commit 86e1138a0476967f79b018a8b8307d5822b7e7e5
@@ -31,7 +31,7 @@
import xml.sax.saxutils

from osgeo import ogr

from qgis.core import QgsProcessingFeedback
from processing.tools import dataobjects
from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
@@ -90,6 +90,9 @@ def mergeDataSources2Vrt(self, dataSources, outFile, union=False, relative=False
@param schema: Schema flag
@return: vrt in string format
'''
if feedback is None:
feedback = QgsProcessingFeedback()

vrt = '<OGRVRTDataSource>'
if union:
vrt += '<OGRVRTUnionLayer name="UnionedLayer">'
@@ -193,7 +193,7 @@ def processBeforeAddingToModeler(self, alg, model):

# =========================================================

def execute(self, feedback=QgsProcessingFeedback(), model=None):
def execute(self, feedback=None, model=None):
"""The method to use to call a processing algorithm.
Although the body of the algorithm is in processAlgorithm(),
@@ -203,6 +203,10 @@ def execute(self, feedback=QgsProcessingFeedback(), model=None):
Raises a GeoAlgorithmExecutionException in case anything goes
wrong.
"""

if feedback is None:
feedback = QgsProcessingFeedback()

self.model = model
try:
self.setOutputCRS()
@@ -48,8 +48,12 @@ def runalg(alg, feedback=None):
Return true if everything went OK, false if the algorithm
could not be completed.
"""

if feedback is None:
feedback = QgsProcessingFeedback()

try:
alg.execute(feedback or QgsProcessingFeedback())
alg.execute(feedback)
return True
except GeoAlgorithmExecutionException as e:
ProcessingLog.addToLog(sys.exc_info()[0], ProcessingLog.LOG_ERROR)

0 comments on commit 86e1138

Please sign in to comment.
You can’t perform that action at this time.