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

Internal indexing problem when adding and removing hooks during same Unity event #384

Open
timsgardner opened this issue Mar 2, 2021 · 0 comments
Assignees

Comments

@timsgardner
Copy link
Contributor

timsgardner commented Mar 2, 2021

To reproduce:

(require '[arcadia.core :as ac])

(def test-obj (UnityEngine.GameObject. "test-obj"))

(def counter (atom 0))

(ac/defrole role-1 
  (update [obj k]
    (ac/role- obj k)
    (ac/state obj k)))

(ac/defrole role-2
  (update [obj k]
    (ac/role+ obj :role-1 role-1)))

(ac/role+ test-obj :role-2 role-2)

The problem seems to be that the length of the ArcadiaBehaviour.ifnInfos array changes as it is being iterated over. In addition to potentially skipping registered functions for the current Unity event, this puts HookStateSystem.ifnInfoIndex in a bad state, leading to this bug.

@timsgardner timsgardner self-assigned this Mar 2, 2021
timsgardner added a commit that referenced this issue Mar 2, 2021
Dereferencing ArcadiaBehaviour.ifnInfos before iterating over it
to avoid invalidating indexes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant