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 Manager does not unload plugins before upgrading them #54968

Closed
alexbruy opened this issue Oct 18, 2023 · 3 comments · Fixed by #55001
Closed

Plugin Manager does not unload plugins before upgrading them #54968

alexbruy opened this issue Oct 18, 2023 · 3 comments · Fixed by #55001
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Plugin manager Windows Related to Windows operating system

Comments

@alexbruy
Copy link
Contributor

alexbruy commented Oct 18, 2023

After downloading a plugin package, Plugin Manager tries to unzip it and overwrite exiting plugin files without unloading the plugin first, see https://github.com/qgis/QGIS/blob/master/python/pyplugin_installer/qgsplugininstallerinstallingdialog.py#L150-L161.

In some cases, when plugin directory contains locked/open files (for example, some resources are open or libraries are loaded) this operation fails on Windows, making it impossible to reinstall/upgrade plugin in a usual way. In that case one has to close QGIS, manually delete plugin folder, then start QGIS again and install plugin.

@alexbruy alexbruy added Bug Either a bug report, or a bug fix. Let's hope for the latter! Plugin manager Windows Related to Windows operating system labels Oct 18, 2023
@alexbruy
Copy link
Contributor Author

@borysiasty do you remember why it was implemented this way?

@borysiasty
Copy link
Member

Hi Alex!
Ooops, my old ugly code...

No particular reason, it was just overlooked. I can fix it if you have a reproducible test case / the affected plugin, or do you prefer to fix it by yourself?

I guess the best place for unloading is before calling that QDialog:
https://github.com/qgis/QGIS/blob/master/python/pyplugin_installer/installer.py#L318

but then the loading back (line 345) should be also performed in lines 323/324, in case the downloading failed or was aborted.

And the same problem applies to installing from a local zip:
https://github.com/qgis/QGIS/blob/master/python/pyplugin_installer/installer.py#L615

@alexbruy
Copy link
Contributor Author

This was found when investigating an issue with Mergin plugin updates (MerginMaps/qgis-plugin#504). While in this particular case unloading plugin is not enough, IMHO this is still a valid issue and Plugin Manager should unload plugin before updating it.

I will prepare PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Plugin manager Windows Related to Windows operating system
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants