[Qgis-developer] Python plugin architecture and renderer plugins

Chris Crook ccrook at linz.govt.nz
Fri Jan 29 16:35:13 EST 2010


Hi Martin

Yes, sounds just what i want.  Though I think it may be called canUninstall, or canUnregister, or something like that.  Because of the potential impact on saved jobs I want to warn the users of what to expect if the remove the login.  I don't want to do this on unload, as that happens every time they shut down qgis.  

Would be great (for me!!) if this function was added to the plugin interface  :-)  

Thanks
Chris
________________________________________
From: Martin Dobias [wonder.sk at gmail.com]
Sent: 29 January 2010 22:49
To: Chris Crook
Cc: qgis-developer at lists.osgeo.org
Subject: Re: [Qgis-developer] Python plugin architecture and renderer plugins

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
______________________________________________________________________________________________________

This message contains information, which is confidential and may be subject to legal privilege. 
If you are not the intended recipient, you must not peruse, use, disseminate, distribute or copy this message.
If you have received this message in error, please notify us immediately (Phone 0800 665 463 or info at linz.govt.nz) and destroy the original message.
LINZ accepts no responsibility for changes to this email, or for any attachments, after its transmission from LINZ.

Thank you.
______________________________________________________________________________________________________


More information about the Qgis-developer mailing list