fix listener resolving to different event description in code Diffs= da8d2d5f7 fix listener resolving to different event (#6528) Co-authored-by: hernan <hernan@rive.app>
diff --git a/.rive_head b/.rive_head index 8bd06d6..3eb8c18 100644 --- a/.rive_head +++ b/.rive_head
@@ -1 +1 @@ -026caa5a9d0e7dc2744b68be5e812fb63bea52a4 +da8d2d5f7f2bc943561676e8d0c282a8725fee15
diff --git a/src/animation/state_machine_instance.cpp b/src/animation/state_machine_instance.cpp index e931676..9c810cc 100644 --- a/src/animation/state_machine_instance.cpp +++ b/src/animation/state_machine_instance.cpp
@@ -695,6 +695,20 @@ for (const auto event : events) { auto sourceArtboard = source == nullptr ? artboard() : source->artboard(); + + // listener->eventId() can point to an id from an event in the context of this + // artboard or the context of a nested artboard. Because those ids belong to + // different contexts, they can have the same value. So when the eventId is + // resolved within one context, but actually pointing to the other, it can + // return the wrong event object. If, by chance, that event exists in the other + // context, and is being reported, it will trigger the wrong set of actions. + // This validation makes sure that a listener must be targetting the current + // artboard to disambiguate between external and internal events. + if (source == nullptr && + sourceArtboard->resolve(listener->targetId()) != artboard()) + { + continue; + } auto listenerEvent = sourceArtboard->resolve(listener->eventId()); if (listenerEvent == event.event()) {