Skip to content

Commit a34583f

Browse files
committed
Fix historic unexpected double activation of interactive tools
1 parent 2690fdf commit a34583f

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ In this release, test coverage is 79%.
1717
* When showing the X/Y cross section plots (using the plot context menu), an empty
1818
label was displayed at the center of each of those plots
1919
* The label now shows "Enable a marker" as previously
20+
* Fix historic unexpected behavior of interactive tools:
21+
* When triggering an interactive tool (e.g. by clicking on the corresponding toolbar
22+
button), the tool `activate` method was called twice, which was not expected, but
23+
was not causing any issue given the current implementation
24+
* However, when defining custom interactive tools, this behavior could lead to
25+
unexpected results (i.e. really executing activation actions twice)
26+
* This is now fixed: the `activate` method is called only once when triggering an
27+
interactive tool
2028

2129
💥 New features / Enhancements:
2230

plotpy/tools/base.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,14 +236,16 @@ def register_plot(self, baseplot: BasePlot) -> None:
236236
filter.set_cursor(curs, start_state)
237237

238238
def interactive_triggered(self, action: QW.QAction) -> None:
239-
"""Slot called when the tool action is triggered
239+
"""Slot called when the interactive tool action group is triggered.
240+
The purpose is to deactivate all other tools in the group.
241+
242+
Note that the tool itself has already been activated because the action
243+
triggered the `activate` method.
240244
241245
Args:
242246
action: tool action
243247
"""
244-
if action is self.action:
245-
self.activate()
246-
else:
248+
if action is not self.action:
247249
self.deactivate()
248250

249251
def activate(self) -> None:

0 commit comments

Comments
 (0)