Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[processing] do not allow editing model if it's missing algorithms
fixes #19607
  • Loading branch information
volaya committed Jan 23, 2019
1 parent e3516ab commit a86965e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions python/plugins/processing/modeler/EditModelAction.py
Expand Up @@ -26,9 +26,11 @@
__revision__ = '$Format:%H$'

from qgis.PyQt.QtCore import QCoreApplication
from qgis.core import QgsApplication, QgsProcessingModelAlgorithm
from qgis.core import QgsApplication, QgsProcessingModelAlgorithm, QgsMessageLog
from processing.gui.ContextAction import ContextAction
from processing.modeler.ModelerDialog import ModelerDialog
from qgis.core import Qgis
from qgis.utils import iface


class EditModelAction(ContextAction):
Expand All @@ -41,9 +43,13 @@ def isEnabled(self):

def execute(self):
alg = self.itemData
dlg = ModelerDialog(alg)
dlg.update_model.connect(self.updateModel)
dlg.show()
ok, msg = alg.canExecute()
if not ok:
iface.messageBar().pushMessage("Cannot edit model:", msg, level=Qgis.Warning)
else:
dlg = ModelerDialog(alg)
dlg.update_model.connect(self.updateModel)
dlg.show()

def updateModel(self):
QgsApplication.processingRegistry().providerById('model').refreshAlgorithms()

0 comments on commit a86965e

Please sign in to comment.