Skip to content
Permalink
Browse files

Merge pull request #4206 from volaya/fix_processing_provider_update

[processing] fixed update of toolbox after editing script providers
  • Loading branch information
volaya committed Mar 3, 2017
2 parents fb409b5 + 51da47d commit e5ebcd170fb19cd985c955da45fc68d8ef040eef
@@ -172,11 +172,12 @@ def removeScripts(folder):
def updateAlgsList():
"""Call this method when there has been any change that
requires the list of algorithms to be created again from
algorithm providers.
algorithm providers. Use reloadProvider() for a more fine-grained
update.
"""
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
for p in Processing.providers:
Processing.reloadProvider(p)
Processing.reloadProvider(p.id())
QApplication.restoreOverrideCursor()

@staticmethod
@@ -38,16 +38,14 @@ class AlgorithmList(QObject):
# and values are list with all algorithms from that provider
algs = {}

providers = []

def removeProvider(self, provider_id):
if provider_id in self.algs:
del self.algs[provider_id]

QgsApplication.processingRegistry().removeProvider(provider_id)

def reloadProvider(self, provider_id):
for p in self.providers:
for p in QgsApplication.processingRegistry().providers():
if p.id() == provider_id:
p.loadAlgorithms()
self.algs[p.id()] = {a.commandLineName(): a for a in p.algs}
@@ -62,8 +62,3 @@ def execute(self):
if self.scriptType == self.SCRIPT_R:
dlg = ScriptEditorDialog(ScriptEditorDialog.SCRIPT_R, None)
dlg.show()
if dlg.update:
if self.scriptType == self.SCRIPT_PYTHON:
algList.reloadProvider('script')
elif self.scriptType == self.SCRIPT_R:
algList.reloadProvider('r')
@@ -50,9 +50,3 @@ def isEnabled(self):
def execute(self):
dlg = ScriptEditorDialog(self.scriptType, self.itemData)
dlg.show()
dlg.exec_()
if dlg.update:
if self.scriptType == ScriptEditorDialog.SCRIPT_PYTHON:
algList.reloadProvider('script')
elif self.scriptType == ScriptEditorDialog.SCRIPT_R:
algList.reloadProvider('r')
@@ -385,7 +385,7 @@ def __init__(self, provider_id, tree, toolbox):

def refresh(self):
self.takeChildren()
Processing.updateAlgsList()
#Processing.updateAlgsList()
self.populate()

def populate(self):
@@ -49,6 +49,7 @@
from processing.algs.r.RUtils import RUtils
from processing.script.ScriptAlgorithm import ScriptAlgorithm
from processing.script.ScriptUtils import ScriptUtils
from processing.core.alglist import algList

pluginPath = os.path.split(os.path.dirname(__file__))[0]
WIDGET, BASE = uic.loadUiType(
@@ -169,12 +170,21 @@ def closeEvent(self, evt):
QMessageBox.Yes | QMessageBox.No, QMessageBox.No
)
if ret == QMessageBox.Yes:
self.updateProviders()
evt.accept()
else:
evt.ignore()
else:
self.updateProviders()
evt.accept()

def updateProviders(self):
if self.update:
if self.algType == self.SCRIPT_PYTHON:
algList.reloadProvider('script')
elif self.algType == self.SCRIPT_R:
algList.reloadProvider('r')

def editHelp(self):
if self.alg is None:
if self.algType == self.SCRIPT_PYTHON:

0 comments on commit e5ebcd1

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