Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin dependencies followup: load dependent plugins after their dependencies on QGIS startup #44906

Merged
merged 4 commits into from
Sep 6, 2021

Conversation

gacarrillor
Copy link
Member

@gacarrillor gacarrillor commented Aug 31, 2021

PR #9619 introduced Python plugin dependencies to QGIS. Besides plugin installation, QGIS should handle dependencies also on QGIS startup, which is currently missing.

This PR is a followup to make sure dependent plugins are only loaded once their dependencies are loaded. Think about a modular plugin that can be extended by other plugins of the same company, depending on the clients. In such a use case, dependent plugins could add new buttons to the main (and independent) plugin's toolbar/menu. For doing so, dependent plugins require the independent plugin to be not only installed first (addressed already by Alessandro P.), but also loaded first on QGIS startup.


The only significant change introduced by this PR is sorting the plugin list that QGIS traverses to load Python plugins. So, for instance, we won't deal with installed but disabled (aka. 'unavailable') plugins, which will need to be handled by plugin devs. Additionally, plugin unload shouldn't be an issue, because in the worst case (i.e., the independent plugin is unloaded first), independent plugins could emit a signal to inform their dependent plugins they'll have to live alone (or simply be unloaded as well) from that moment on. Therefore, plugin unload is not addressed in this PR, as in my opinion can be left to plugin devs.

As it is, this PR will also work for qgis_process and, as far as I know, for qgis_server plugins (although I'm not sure if the server supports plugin dependencies as well), which also traverse the mPythonUtils->pluginList() to load plugins.

Since QGIS code calls updateAvailablePlugins() from several parts, but only one of those needs the plugin list sorted, I ensured we only ask for a sorted list when loading plugins, and the other calls remain getting the original (unsorted) plugin list.

Several unit tests were added, for both C++ and Python.


@elpaso, since you implemented the basis for plugin dependencies, and I'm moving one of your methods, I'd acknowledge if you can have a look at this PR.


Funded by SwissTierras-Colombia.

@github-actions github-actions bot added this to the 3.22.0 milestone Aug 31, 2021
…PythonUtils->pluginList(), which will be the order used to load Python plugins to QGIS
Copy link
Contributor

@elpaso elpaso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's been a while since I wrote that code so I'm not 100% sure but your improvement looks good to me, very useful indeed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants