Skip to content

Commit

Permalink
Lua API: implicitly clear animator after playing it (#3536)
Browse files Browse the repository at this point in the history
This prevents the animator from holding a strong reference to the target unit, which was keeping the unit object alive and thus preventing the unit halo, if any, from disappearing.
  • Loading branch information
newfrenchy83 authored and jyrkive committed Sep 9, 2018
1 parent 6eba0cb commit 7d6e2b2
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions data/lua/wml/animate_unit.lua
Expand Up @@ -110,5 +110,4 @@ function wesnoth.wml_actions.animate_unit(cfg)
local anim = wesnoth.create_animator()
add_animation(anim, cfg)
anim:run()
anim:clear()
end
end
1 change: 0 additions & 1 deletion data/lua/wml/heal_unit.lua
Expand Up @@ -44,7 +44,6 @@ function wesnoth.wml_actions.heal_unit(cfg)
animator:add(healers[1], 'healing', 'hit', {value = heal_amount})
end
animator:run()
animator:clear()
end

u.hitpoints = new_hitpoints
Expand Down
1 change: 0 additions & 1 deletion data/lua/wml/kill.lua
Expand Up @@ -71,7 +71,6 @@ function wesnoth.wml_actions.kill(cfg)
anim:add(secondary_unit, "victory", "kill", {primary = secondary, secondary = primary})
end
anim:run()
anim:clear()
end
-- wesnoth.wml_actions.redraw{}

Expand Down
1 change: 1 addition & 0 deletions src/scripting/game_lua_kernel.cpp
Expand Up @@ -449,6 +449,7 @@ static int impl_run_animation(lua_State* L)
anim.start_animations();
anim.wait_for_end();
anim.set_all_standing();
anim.clear();
return 0;
}

Expand Down

0 comments on commit 7d6e2b2

Please sign in to comment.