[processing] Correctly handle when no feedback object is passed

This commit is contained in:
Nyall Dawson 2017-01-07 07:31:31 +10:00
parent ede452be85
commit 86e1138a04
3 changed files with 14 additions and 3 deletions

View File

@ -31,7 +31,7 @@ import codecs
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 @@ class Datasources2Vrt(GeoAlgorithm):
@param schema: Schema flag
@return: vrt in string format
'''
if feedback is None:
feedback = QgsProcessingFeedback()
vrt = '<OGRVRTDataSource>'
if union:
vrt += '<OGRVRTUnionLayer name="UnionedLayer">'

View File

@ -193,7 +193,7 @@ class GeoAlgorithm(object):
# =========================================================
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 @@ class GeoAlgorithm(object):
Raises a GeoAlgorithmExecutionException in case anything goes
wrong.
"""
if feedback is None:
feedback = QgsProcessingFeedback()
self.model = model
try:
self.setOutputCRS()

View File

@ -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)