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

Support removing absent tools from ToolContainerBase. #28171

Merged
merged 1 commit into from May 6, 2024

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented May 4, 2024

ToolManager.remove_tool calls ToolContainerBase.remove_toolitem (via a tool_removed_event) and cannot know (due to the lack of API) whether the tool is actually on the container (it can also be a keybind-only tool not associated with any entry on the toolbar), so ToolContainerBase.remove_toolitem should work (as a no-op) even for tools not present on the container (and not even set a message in that case, IMO).

Closes #28166 (see example there). Again I'd say this is a symptom of the MEP22 design (toolmanager not knowing whether a tool is actually in the toolcontainer makes things awkward), but let's just go for the minimal fix.

PR summary

PR checklist

ToolManager.remove_tool calls ToolContainerBase.remove_toolitem
(via a tool_removed_event) and cannot know (due to the lack of API)
whether the tool is actually on the container (it can also be a
keybind-only tool not associated with any entry on the toolbar), so
ToolContainerBase.remove_toolitem should work (as a no-op) even for
tools not present on the container.
@QuLogic QuLogic added this to the v3.9.0 milestone May 6, 2024
@QuLogic QuLogic merged commit 67aee6c into matplotlib:main May 6, 2024
42 of 44 checks passed
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request May 6, 2024
@anntzer anntzer deleted the rt branch May 6, 2024 17:42
QuLogic added a commit that referenced this pull request May 7, 2024
…171-on-v3.9.x

Backport PR #28171 on branch v3.9.x (Support removing absent tools from ToolContainerBase.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Removing tools from the toolmanager that are not on the toolbar triggers an exception
3 participants