[processing] improvements for new mechanism for adding algorithms

Correctly remove algorithms on plugin unload
This commit is contained in:
volaya 2016-05-24 10:27:38 +02:00
parent bc75862e53
commit 3607e269c6
3 changed files with 11 additions and 4 deletions

View File

@ -32,7 +32,7 @@ from processing.core.Processing import Processing
class ProcessingExampleScriptsPlugin:
def initGui(self):
Processing.addScripts(self, os.path.dirname(__file__))
Processing.addScripts(os.path.join(os.path.dirname(__file__), "scripts"))
def unload(self):
pass
Processing.removeScripts(os.path.join(os.path.dirname(__file__), "scripts"))

View File

@ -150,9 +150,16 @@ class Processing:
provider.externalAlgs.extend(scripts)
Processing.reloadProvider("qgis")
@staticmethod
@staticmethod
def removeScripts(folder):
pass
provider = Processing.getProviderFromName("qgis")
for alg in provider.externalAlgs[::-1]:
path = os.path.dirname(alg.descriptionFile)
if path == folder:
provider.externalAlgs.remove(alg)
Processing.reloadProvider("qgis")
@staticmethod
def updateAlgsList():