Skip to content
Permalink
Browse files

[processing] Fix multiple error dialogs in batch processes

Errors when postprocessing layers are now added to the log console
  • Loading branch information
volaya committed Sep 29, 2015
1 parent 1c69373 commit 67d70f8572466fbb0267be280c5f8d51cb1a0da2
@@ -85,6 +85,7 @@ def __init__(self, alg):
self.showDebug = ProcessingConfig.getSetting(
ProcessingConfig.SHOW_DEBUG_IN_DIALOG)


def closeEvent(self, evt):
self.settings.setValue("/Processing/dialogBase", self.saveGeometry())

@@ -107,7 +108,7 @@ def resetGUI(self):

def setInfo(self, msg, error=False):
if error:
self.txtLog.append('<span style="color:red">%s</span>' % msg)
self.txtLog.append('<span style="color:red"><br>%s<br></span>' % msg)
else:
self.txtLog.append(msg)
QCoreApplication.processEvents()
@@ -17,6 +17,7 @@
***************************************************************************
"""


__author__ = 'Victor Olaya'
__date__ = 'April 2013'
__copyright__ = '(C) 2013, Victor Olaya'
@@ -29,11 +30,13 @@
from PyQt4.QtGui import QProgressBar
from qgis.utils import iface
from qgis.gui import QgsMessageBar

from processing.core.ProcessingLog import ProcessingLog
from processing.gui.MessageDialog import MessageDialog

class MessageBarProgress:

def __init__(self, algname=None):
self.msg = []
self.progressMessageBar = \
iface.messageBar().createMessage(self.tr('Executing algorithm <i>{0}</i>'.format(algname if algname else '')))
self.progress = QProgressBar()
@@ -44,9 +47,8 @@ def __init__(self, algname=None):
iface.messageBar().INFO)

def error(self, msg):
iface.messageBar().clearWidgets()
iface.messageBar().pushMessage(self.tr('Error'),
msg, level=QgsMessageBar.CRITICAL, duration=3)
self.msg.append(msg)


def setText(self, text):
pass
@@ -67,6 +69,11 @@ def setConsoleInfo(self, _):
pass

def close(self):
if self.msg:
dlg = MessageDialog()
dlg.setTitle(QCoreApplication.translate('MessageBarProgress', 'Problem executing algorithm'))
dlg.setMessage("<br>".join(self.msg))
dlg.exec_()
iface.messageBar().clearWidgets()

def tr(self, string, context=''):
@@ -77,18 +77,16 @@ def handleAlgorithmResults(alg, progress=None, showResults=True):
ProcessingResults.addResult(out.description, out.value)
htmlResults = True
i += 1

QApplication.restoreOverrideCursor()
if wrongLayers:
QApplication.restoreOverrideCursor()
dlg = MessageDialog()
dlg.setTitle(QCoreApplication.translate('Postprocessing', 'Problem loading output layers'))
msg = "The following layers were not correctly generated.<ul>"
msg += "".join(["<li>%s</li>" % lay for lay in wrongLayers]) + "</ul>"
msg += "You can check the <a href='log'>log messages</a> to find more information about the execution of the algorithm"
dlg.setMessage(msg)
dlg.exec_()
msg += "You can check the log messages to find more information about the execution of the algorithm"
progress.error(msg)


if showResults and htmlResults and not wrongLayers:
QApplication.restoreOverrideCursor()
dlg = ResultsDialog()
dlg.exec_()

0 comments on commit 67d70f8

Please sign in to comment.
You can’t perform that action at this time.