I programmed one processing provider and four processing algorithms for a custom plugin. Loading the plugin through the Plugin Manager works fine, and the algorithms also run as expected when started.
However, I don't know how to clean up the processing provider when it's unloaded. I suspect it has to do with my MyProvider(QgsProcessingProvider)::unload() function, but I don't know what to change.
The template I used comes from the QGIS Plugin Builder. Since it creates one provider per algorithm, I changed the code and created a separate MyProvider class in its separate file. In its loadAlgorithms(), it loads all four algorithms, which work perfectly fine.
However, when the plugin is 'unloaded' through the Plugin Manager, neither the algorithms nor their provider disappear from the Processing Toolbox. Just their names disappear; the entries stay. When reloaded, their names don't show up, and they don't work anymore. The displayed error says:
_core.QgsProcessingException: Error creating algorithm from createInstance() I guess createInstance() fails because the name of the algorithm is missing, but what did I do wrong in the first place?
Some MyProvider class code:
from .algo1.algo1_algorithm import Algo1 class MyOMProvider(QgsProcessingProvider): def __init__(self): QgsProcessingProvider.__init__(self) def initGui(self): self.initProcessing() def initProcessing(self): QgsApplication.processingRegistry().addProvider(self) def loadAlgorithms(self): self.addAlgorithm(Algo1()) self.addAlgorithm(Algo2()) self.addAlgorithm(Algo3()) self.addAlgorithm(Algo4()) def unload(self): # What to do here? pass