HearthSim / Hearthstone-Deck-Tracker

A deck tracker and deck manager for Hearthstone on Windows
https://hsreplay.net/downloads/
4.65k stars 1.11k forks source link

[Bug] Multiple GameEvents registration with plugins #3079

Open djdookie opened 7 years ago

djdookie commented 7 years ago

Bug report

Expected Behavior

If any plugin registers for a GameEvent, and is disabled and reenabled, it should only fire once if that event occurs.

Actual Behavior

If you reenable a plugin several times, you're related plugin's event-method is triggered several times.

Steps to reproduce behavior

  1. Enable plugin which register's for any game event (e.g. OpponentPlays card)
  2. Disable plugin
  3. Reenable plugin
  4. Attach your debugger to the HDT process
  5. Set breakpoint on the method for processing chosen gameevent
  6. Let the game activate that event (e.g. let the opponent play a card)
  7. Watch your breakpoint be hit several times instead of only once

Log/Screenshots

not needed

Possible solutions

a) In the Hearthstone_Deck_Tracker.API.ActionList.Add() method, check for duplicates before adding new tuples. b) Implement ActionList.Remove() to allow a plugin to unregister events in OnUnload(). c) Make the content of _actions public or accessible by a plugin (via method or property), so it can check and prevent multiple registrations of events by itself

Additional info

Two month ago, a cleanup of actions was implemented for disabled addons. But this is only done if an action is triggered, not if the plugin gets disabled! See: https://github.com/HearthSim/Hearthstone-Deck-Tracker/commit/38be9ede1bdb847f8efb09184f1938172c72b329

djdookie commented 7 years ago

No one?

djdookie commented 7 years ago

Could anyone confirm and solve this behaviour please?