Skip to content

Commit

Permalink
removed previous cancelation mechanism (not used)
Browse files Browse the repository at this point in the history
fixed #5777

git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@237 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
volayaf@gmail.com committed Jun 11, 2012
1 parent f2d4561 commit f284e29
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/sextante/core/GeoAlgorithm.py
Expand Up @@ -33,7 +33,10 @@ def __init__(self):
#true if the algorithm has been canceled while it was being executed
#default value is false, so it should be changed in processAlgorithm only if the algorithm
#gets canceled
self.canceled = False
#self.canceled = False

#to be set by the provider when it loads the algorithm
self.provider = None

self.defineCharacteristics()

Expand Down Expand Up @@ -105,15 +108,12 @@ def execute(self, progress):
Although the body of the algorithm is in processAlgorithm(),
it should be called using this method, since it performs
some additional operations.
The return value indicates whether the algorithm was canceled (false)
or successfully run (true).
Raises a GeoAlgorithmExecutionException in case anything goes wrong.'''
self.setOutputCRSFromInputLayers()
self.resolveTemporaryOutputs()
self.checkOutputFileExtensions()
try:
self.processAlgorithm(progress)
return not self.canceled
except GeoAlgorithmExecutionException, gaee:
SextanteLog.addToLog(SextanteLog.LOG_ERROR, gaee.msg)
raise gaee
Expand Down
14 changes: 9 additions & 5 deletions src/sextante/gui/AlgorithmExecutor.py
Expand Up @@ -19,7 +19,7 @@ def __init__(self, alg, iterParam = None, parent = None):
QThread.__init__(self, parent)
self.algorithm = alg
self.parameterToIterate = iterParam

class Progress:
def __init__(self, algex):
self.algorithmExecutor = algex
Expand Down Expand Up @@ -53,8 +53,10 @@ def setPercentage(self, p):
def runalg(self):
try:
self.algorithm.execute(self.progress)
if self.algorithm.canceled:
self.canceled.emit()
#===================================================================
# if self.algorithm.canceled:
# self.canceled.emit()
#===================================================================
except GeoAlgorithmExecutionException, e :
self.error.emit()
except:
Expand All @@ -76,7 +78,9 @@ def runalgIterating(self):
self.progress.setText("Executing iteration " + str(i) + "/" + str(len(self.filelist)) + "...")
self.progress.setPercentage((i * 100) / len(self.filelist))
self.runalg()
if self.algorithm.canceled:
return
#===================================================================
# if self.algorithm.canceled:
# return
#===================================================================
self.iterated.emit(i)
i += 1
2 changes: 2 additions & 0 deletions src/sextante/modeler/ModelerDialog.py
Expand Up @@ -193,6 +193,8 @@ def runModel(self):
self.alg.descriptionFile = None
alg.descriptionFile = None
else:
if self.alg.provider is None: # might happen if model is opened from modeler dialog
self.alg.provider = Providers.providers["model"]
alg = self.alg.getCopy()
dlg = ParametersDialog(alg)
dlg.exec_()
Expand Down
30 changes: 25 additions & 5 deletions src/sextante/modeler/ModelerParametersDialog.py
Expand Up @@ -440,6 +440,23 @@ def setParamBooleanValue(self, param, widget):
self.params[param.name] = value
return True

def setParamTableFieldValue(self, param, widget):
idx = widget.findText(widget.currentText())
if idx < 0:
name = self.getSafeNameForHarcodedParameter(param)
value = AlgorithmAndParameter(AlgorithmAndParameter.PARENT_MODEL_ALGORITHM, name)
self.params[param.name] = value
value = str(widget.currentText()).strip()
if value == "":
return False
else:
self.values[name] = str(widget.currentText())
return True
else:
value = widget.itemData(widget.currentIndex()).toPyObject()
self.params[param.name] = value
return True

def setParamStringValue(self, param, widget):
idx = widget.findText(widget.currentText())
if idx < 0:
Expand Down Expand Up @@ -516,11 +533,14 @@ def setParamValue(self, param, widget):
self.values[name] = ParameterFixedTable.tableToString(widget.table)
return True
if isinstance(param, ParameterTableField):
name = self.getSafeNameForHarcodedParameter(param)
value = AlgorithmAndParameter(AlgorithmAndParameter.PARENT_MODEL_ALGORITHM, name)
self.params[param.name] = value
self.values[name] = str(widget.text())
return True
return self.setParamTableFieldValue(param, widget)
#===================================================================
# name = self.getSafeNameForHarcodedParameter(param)
# value = AlgorithmAndParameter(AlgorithmAndParameter.PARENT_MODEL_ALGORITHM, name)
# self.params[param.name] = value
# self.values[name] = str(widget.text())
# return True
#===================================================================
elif isinstance(param, ParameterMultipleInput):
if param.datatype == ParameterMultipleInput.TYPE_VECTOR_ANY:
options = self.getVectorLayers()
Expand Down

0 comments on commit f284e29

Please sign in to comment.