[Qgis-developer] Python plugin architecture and renderer plugins

Martin Dobias wonder.sk at gmail.com
Fri Jan 29 04:49:43 EST 2010


On Tue, Jan 26, 2010 at 10:49 PM, Chris Crook <ccrook at linz.govt.nz> wrote:
> The problem is with the unload function of the class factory.  I cannot
> unload the plugin if there are current layers rendered using it, so ideally
> what I want to do is to be able to cancel the unload, or at least postpone
> it till Quantum exits.
>
> The other thing I want to do is notify users that if they do unload the
> plugin that they may not be able to reload projects which contain layers
> rendered using the plugin renderer - if it is no longer installed then the
> project will fail to reload the layers.
>
> I thought I could do this in the unload function by displaying a dialog
> box.  However the unload function is called when Quantum exits, as well as
> when the plugin is unregistered.   I don't want the dialog to pop up every
> time the user exits.
>
> It looks like I need an uninstall function in the class factory, which is
> called by the plugin manager before it is uninstalled, and which can cancel
> the uninstall.
>
> Is there any such function?

Currently there's no such function that would enable the plugins ask
for confirmation. But that doesn't mean it can't be added :-)
So I believe you need a function, e.g.: canUnload() in plugin's
interface. It would be called from plugin manager (and installer) when
users disables the plugin and it would return True/False to indicate
whether the plugin can be unloaded.

Anyway plugin's unload() method should take care of the layers having
a renderer which is going to be unloaded: it may try to go through all
layers in QgsMapLayerRegistry and reset the renderer for affected
layers to a default one.

In future we might need to create generic dependency tracking, so it
should be clear whether the plugin is safe to unload and if not, which
objects depend on it.

Regards
Martin


More information about the Qgis-developer mailing list