mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-15 00:07:25 -05:00
[processing] added check to ensure input layers are valid
This commit is contained in:
parent
247c2f061e
commit
83f3a5893c
@ -246,6 +246,21 @@ class GeoAlgorithm:
|
||||
raise GeoAlgorithmExecutionException(
|
||||
str(e) + self.tr('\nSee log for more details'))
|
||||
|
||||
def _checkParameterValuesBeforeExecuting(self):
|
||||
for param in self.parameters:
|
||||
if isinstance(param, (ParameterRaster, ParameterVector,
|
||||
ParameterMultipleInput)):
|
||||
if param.value:
|
||||
if isinstance(param, ParameterMultipleInput):
|
||||
inputlayers = param.value.split(';')
|
||||
else:
|
||||
inputlayers = [param.value]
|
||||
for inputlayer in inputlayers:
|
||||
obj = dataobjects.getObjectFromUri(inputlayer)
|
||||
if obj is None:
|
||||
return "Wrong parameter value: " + param.value
|
||||
return self.checkParameterValuesBeforeExecuting()
|
||||
|
||||
def runPostExecutionScript(self, progress):
|
||||
scriptFile = ProcessingConfig.getSetting(
|
||||
ProcessingConfig.POST_EXECUTION_SCRIPT)
|
||||
|
||||
@ -327,7 +327,7 @@ class Processing:
|
||||
return
|
||||
i = i + 1
|
||||
|
||||
msg = alg.checkParameterValuesBeforeExecuting()
|
||||
msg = alg._checkParameterValuesBeforeExecuting()
|
||||
if msg:
|
||||
print 'Unable to execute algorithm\n' + msg
|
||||
return
|
||||
|
||||
@ -156,7 +156,7 @@ class AlgorithmDialog(AlgorithmDialogBase):
|
||||
QMessageBox.No)
|
||||
if reply == QMessageBox.No:
|
||||
return
|
||||
msg = self.alg.checkParameterValuesBeforeExecuting()
|
||||
msg = self.alg._checkParameterValuesBeforeExecuting()
|
||||
if msg:
|
||||
QMessageBox.warning(
|
||||
self, self.tr('Unable to execute algorithm'), msg)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user