Skip to content

Commit

Permalink
[processing] Use a proxy task for batch processing execution
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Sep 7, 2018
1 parent 5030121 commit db16008
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions python/plugins/processing/gui/BatchAlgorithmDialog.py
Expand Up @@ -40,7 +40,8 @@
QgsProcessingOutputNumber,
QgsProcessingOutputString,
QgsProject,
Qgis)
Qgis,
QgsScopedProxyProgressTask)

from qgis.gui import QgsProcessingAlgorithmDialogBase
from qgis.utils import OverrideCursor
Expand Down Expand Up @@ -115,6 +116,8 @@ def accept(self):

alg_parameters.append(parameters)

task = QgsScopedProxyProgressTask(self.tr('Batch Processing - {0}').format(self.algorithm().displayName()))

with OverrideCursor(Qt.WaitCursor):

self.mainWidget().setEnabled(False)
Expand All @@ -135,6 +138,7 @@ def accept(self):
break
self.setProgressText(QCoreApplication.translate('BatchAlgorithmDialog', '\nProcessing algorithm {0}/{1}…').format(count + 1, len(alg_parameters)))
self.setInfo(self.tr('<b>Algorithm {0} starting&hellip;</b>').format(self.algorithm().displayName()), escapeHtml=False)
task.setProgress(100 * count / len(alg_parameters))

parameters = self.algorithm().preprocessParameters(parameters)

Expand Down Expand Up @@ -165,6 +169,7 @@ def accept(self):
handleAlgorithmResults(self.algorithm(), context, feedback, False)

feedback.pushInfo(self.tr('Batch execution completed in {0:0.2f} seconds'.format(time.time() - start_time)))
task = None

self.finish(algorithm_results)
self.cancelButton().setEnabled(False)
Expand All @@ -175,8 +180,6 @@ def finish(self, algorithm_results):

self.createSummaryTable(algorithm_results)
self.mainWidget().setEnabled(True)
QMessageBox.information(self, self.tr('Batch processing'),
self.tr('Batch processing completed'))

def loadHTMLResults(self, results, num):
for out in self.algorithm().outputDefinitions():
Expand Down

0 comments on commit db16008

Please sign in to comment.