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

onChangeSelection event fires too many times #1468

Closed
Merudo opened this issue Apr 6, 2020 · 4 comments
Closed

onChangeSelection event fires too many times #1468

Merudo opened this issue Apr 6, 2020 · 4 comments
Assignees
Labels
bug macro changes This issue adds or changes macro functions. Extra work is required (testing, wiki, code editor) tested This issue has been QA tested by someone other than the developer.

Comments

@Merudo
Copy link
Member

Merudo commented Apr 6, 2020

Describe the bug
The event onChangeSelection fires too many times. This leads to macros being executed multiple times instead of once, lagging the system and possibly causing bugs.

To Reproduce
Steps to reproduce the behavior:

  1. Creates a macro on the campaign panel called print with [r: macro.args] inside
  2. Creates this macro:
[h: processorLink = macroLinkText("print@Campaign", "all", "event fired")]
[frame("Test"):{<link rel='onChangeSelection' type='macro' href='[r:processorLink]'>}]
  1. Launch the macro, and select/unselect tokens. Clicking on a token causes it to be executed 2 or more times.
  • Selecting a token: fired 4 times
  • Selecting the same token: fired 3 times
  • Dragging a selection rectangle stoken / unselecting all tokens : fired 2 times

Expected behavior
The onChangeSelection event is only fired once.

MapTool Info

  • Version: 1.5.14, 1.6.0 beta 2
  • Install: New

Desktop (please complete the following information):

  • OS: Windows
  • Version: 10
@JamzTheMan
Copy link
Member

Yes, that's a stupid bug that needs to be squashed and usually requires hacks to prevent macros from running multiple times which is painful.

Is this the only event macro that fires multiple times?

@Merudo
Copy link
Member Author

Merudo commented Apr 6, 2020

I don't know a thing about onChangeImpersonated as I almost never use impersonation.

When I changed macros to update the properties of interest instead of sending the whole token every time, I tried to keep onChangeToken firing once per macro command. I suspect there might be a few cases of duplicated firing in there, though.

EDIT: moving a token through the GUI fires onChangeToken twice

Merudo added a commit to Merudo/maptool that referenced this issue Apr 6, 2020
- Fix onChangeSelection firing 2-4 times per token selection change
- Close RPTools#1468
@Merudo
Copy link
Member Author

Merudo commented Apr 6, 2020

PR #1470 fixes this for onChangeSelection, and the movement for onChangeToken.

Merudo added a commit to Merudo/maptool that referenced this issue Apr 6, 2020
- Fix onChangeSelection firing 2-4 times per token selection change
- Fix onTokenChange firing 2 times per token move
- Close RPTools#1468
@Phergus Phergus added the bug label Apr 6, 2020
@Phergus Phergus added the macro changes This issue adds or changes macro functions. Extra work is required (testing, wiki, code editor) label Apr 6, 2020
@Phergus
Copy link
Contributor

Phergus commented Apr 6, 2020

Tested with test case provided and modified to include onChangeToken event. Only single events observed for selection, deselection and moving of tokens.

@Phergus Phergus closed this as completed Apr 6, 2020
@Phergus Phergus added the tested This issue has been QA tested by someone other than the developer. label Apr 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug macro changes This issue adds or changes macro functions. Extra work is required (testing, wiki, code editor) tested This issue has been QA tested by someone other than the developer.
Projects
None yet
Development

No branches or pull requests

3 participants