fixed inconsistent global animation state after event actions
authorHolger Schemel <info@artsoft.org>
Thu, 21 Mar 2019 23:05:57 +0000 (00:05 +0100)
committerHolger Schemel <info@artsoft.org>
Thu, 21 Mar 2019 23:05:57 +0000 (00:05 +0100)
When executing event actions for global animations, these actions may
cause a screen change, which itself may change the state of global
animations (especially stopping animations that were running on the
previous screen).

When executing event actions directly from the functions that handle
global animations, these functions may continue changing the state of
the global animation that caused the event action, even though this
animation was already stopped due to a screen change, which may cause
this animation to be set back to "active" ("running") state, so that
it continues being displayed on the new screen, even though it was
never defined for it.

This problem was fixed by executing all event actions independently
from the animation handling functions, by inserting new user events
into the program's standard event queue, to handle animation event
actions in a separate, independent step after all animations were
handled.

src/anim.c
src/events.c
src/events.h

index 71f9958857020ce938ee3edc49277b18333fa9a0..6fe1cb6dc3c0ba638f5a8be3f237cbb7a17d36c1 100644 (file)
@@ -1638,15 +1638,13 @@ static boolean DoGlobalAnim_EventAction(struct GlobalAnimPartControlInfo *part)
   if (anim_event_action == -1)
     return FALSE;
 
-  boolean action_executed = (DoGadgetAction(anim_event_action) ||
-                            DoScreenAction(anim_event_action) ||
-                            DoKeysymAction(anim_event_action));
+  PushUserEvent(USEREVENT_ANIM_EVENT_ACTION, anim_event_action, 0);
 
   // check if further actions are allowed to be executed
   if (part->control_info.style & STYLE_MULTIPLE_ACTIONS)
     return FALSE;
 
-  return action_executed;
+  return TRUE;
 }
 
 static void InitGlobalAnim_Clickable(void)
index 11fd28f40035daab17fc49caf6e05a0995b8262c..17f528e9415aadc78f26f411a7d550e5292c2553 100644 (file)
@@ -1607,6 +1607,14 @@ void HandleUserEvent(UserEvent *event)
 {
   switch (event->code)
   {
+    case USEREVENT_ANIM_EVENT_ACTION:
+      // execute action functions until matching action was found
+      if (DoKeysymAction(event->value1) ||
+         DoGadgetAction(event->value1) ||
+         DoScreenAction(event->value1))
+       return;
+      break;
+
     default:
       break;
   }
index ef61b60590ee784ae7213a896aea98b7f51d3d4a..deba7439368d40774196b634c5b656bbc7bed85e 100644 (file)
 
 #include "main.h"
 
+
+#define USEREVENT_NONE                 0
+#define USEREVENT_ANIM_EVENT_ACTION    1
+
+
 boolean NextValidEvent(Event *);
 
 void EventLoop(void);