Skip to content

Commit a86965e

Browse files
committedJan 23, 2019
[processing] do not allow editing model if it's missing algorithms
fixes #19607
1 parent e3516ab commit a86965e

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed
 

‎python/plugins/processing/modeler/EditModelAction.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@
2626
__revision__ = '$Format:%H$'
2727

2828
from qgis.PyQt.QtCore import QCoreApplication
29-
from qgis.core import QgsApplication, QgsProcessingModelAlgorithm
29+
from qgis.core import QgsApplication, QgsProcessingModelAlgorithm, QgsMessageLog
3030
from processing.gui.ContextAction import ContextAction
3131
from processing.modeler.ModelerDialog import ModelerDialog
32+
from qgis.core import Qgis
33+
from qgis.utils import iface
3234

3335

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

4244
def execute(self):
4345
alg = self.itemData
44-
dlg = ModelerDialog(alg)
45-
dlg.update_model.connect(self.updateModel)
46-
dlg.show()
46+
ok, msg = alg.canExecute()
47+
if not ok:
48+
iface.messageBar().pushMessage("Cannot edit model:", msg, level=Qgis.Warning)
49+
else:
50+
dlg = ModelerDialog(alg)
51+
dlg.update_model.connect(self.updateModel)
52+
dlg.show()
4753

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

0 commit comments

Comments
 (0)
Please sign in to comment.