Skip to content

[codex] Fix QGIS plugin reload cleanup - #18

Open
giswqs wants to merge 2 commits into
mainfrom
codex/fix-plugin-reload-cleanup
Open

[codex] Fix QGIS plugin reload cleanup#18
giswqs wants to merge 2 commits into
mainfrom
codex/fix-plugin-reload-cleanup

Conversation

@giswqs

@giswqs giswqs commented May 12, 2026

Copy link
Copy Markdown
Member

Summary

Fix QGIS Plugin Reloader warnings caused by custom plugin toolbars and menus that can remain attached to the QGIS main window after unload().

Changes

  • Remove stale plugin toolbars by object name before creating a new toolbar.
  • Detach and schedule stale toolbars for deletion during unload.
  • Remove stale plugin menus by title before initialization and during unload.
  • Keep cleanup best-effort so reload/unload can continue even if QGIS has already detached a widget.

Validation

  • Ran python -m py_compile on the changed plugin entry-point file.
  • Ran git diff --check.

Copilot AI review requested due to automatic review settings May 12, 2026 04:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR improves QGIS plugin reload/unload hygiene by proactively cleaning up Leafmap’s custom toolbar and menu so they don’t remain attached to the QGIS main window after unload() (reducing QGIS Plugin Reloader warnings).

Changes:

  • Add helper methods to locate and detach stale Leafmap toolbars (by objectName) and menus (by title).
  • Run cleanup during initGui() before creating a new menu/toolbar to avoid duplicates after reload.
  • Run cleanup during unload() to ensure widgets are detached and scheduled for deletion.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread qgis_leafmap/qgis_leafmap.py
Comment thread qgis_leafmap/qgis_leafmap.py
Comment thread qgis_leafmap/qgis_leafmap.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants