[QGIS-Developer] Understanding inter-plugin dependencies and plugin loading - what can a plugin expect from a dependency?
Sebastian M. Ernst
ernst at pleiszenburg.de
Wed Apr 29 09:07:55 PDT 2020
thanks for the answer!
> [...] it is probably useful to distinguish two situations:
> 1. installation of a plugin that depends on another one
> 2. plugin loading when QGIS application start
Yes, exactly. I am interested in situation 2 and all of its associated
> For (2) you can have a plugin listen to initializationCompleted, at
> that point in time all your plugins will be loaded, and the plugin can
> make its own "post-initialization".
I'd agree to that. Let's just say PluginA depends on functionality of
PluginB. PluginB could be a "library" for PluginA (and other plugins)
but also potentially offer some functionality to a user directly.
Scenario A: If PluginB was not waiting for `initializationCompleted`
then all of its stuff would be present by the time PluginA has waited
for `initializationCompleted`. Ok, this would solve a few (edge?) cases.
Scenario B: Both plugins wait for `initializationCompleted` (or both do
not). It is either PluginA which gets to go first or PluginB. It's not
deterministic which plugin "receives" `initializationCompleted` first.
You're again stuck in a situation where there is no guarantee for
PluginA to work as expected - unless its author taps into `qgis.utils`
and does some non-trivial error handling.
I am not trying to solve a specific problem (yet). I am more interested
in how this mechanism is supposed to be correctly used by plugins like
PluginA and PluginB at the moment ... as in the kind of recommendations
or "best practices" that should be encouraged (and documented). Once I
have understood that, I'd like to figure out what kind of potential
subsequent problems have to be addressed then (or whether there are any
problems at all).
I'd also (more or less independently) like to know how much of the API
in `qgis.utils` is a "fair target" for plugin authors and how much of
this API is entirely meant to be "private" (and should not be touched by
More information about the QGIS-Developer