Skip to content

Commit

Permalink
Fix historic unexpected double activation of interactive tools
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreRaybaut committed Jul 24, 2024
1 parent 2690fdf commit a34583f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ In this release, test coverage is 79%.
* When showing the X/Y cross section plots (using the plot context menu), an empty
label was displayed at the center of each of those plots
* The label now shows "Enable a marker" as previously
* Fix historic unexpected behavior of interactive tools:
* When triggering an interactive tool (e.g. by clicking on the corresponding toolbar
button), the tool `activate` method was called twice, which was not expected, but
was not causing any issue given the current implementation
* However, when defining custom interactive tools, this behavior could lead to
unexpected results (i.e. really executing activation actions twice)
* This is now fixed: the `activate` method is called only once when triggering an
interactive tool

💥 New features / Enhancements:

Expand Down
10 changes: 6 additions & 4 deletions plotpy/tools/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,16 @@ def register_plot(self, baseplot: BasePlot) -> None:
filter.set_cursor(curs, start_state)

def interactive_triggered(self, action: QW.QAction) -> None:
"""Slot called when the tool action is triggered
"""Slot called when the interactive tool action group is triggered.
The purpose is to deactivate all other tools in the group.
Note that the tool itself has already been activated because the action
triggered the `activate` method.
Args:
action: tool action
"""
if action is self.action:
self.activate()
else:
if action is not self.action:
self.deactivate()

def activate(self) -> None:
Expand Down

0 comments on commit a34583f

Please sign in to comment.