1

Is it possible to listen for plugin removal before the plugin is removed?

We save global settings as user interacts with the plugin, but want to reset plugin specific global settings when user uninstalls the plugin.

James Park
  • 23
  • 2

1 Answers1

2

You can use the unload() method of your plugin, which is called also when your plugin is uninstalled.

So, the best place to do your cleaning is there, the unload().


See What is the purpose of some functions and files in QGIS Python plugins? for details.

Germán Carrillo
  • 36,307
  • 5
  • 123
  • 178
  • This seems to invoke when I close QGIS client as well. I want a signal when plugin is uninstalled, not necessarily when plugin is unloaded. – James Park Jul 22 '20 at 05:04
  • 1
    Then, it doesn't exist. There will always be edge cases, like a user removing the plugin folder manually in the file explorer. You simply won't be able to react to such case. Anyways, I'd suggest you to think again about/adjust your implementation, or, to create a feature request for QGIS. – Germán Carrillo Jul 23 '20 at 14:54
  • Thank you for clarification. – James Park Jul 23 '20 at 20:48