mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
[processing] Correctly handle when no feedback object is passed
This commit is contained in:
parent
ede452be85
commit
86e1138a04
@ -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">'
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user