[Commits] [wesnoth/wesnoth] 823d8c: use UnitPtr (intrusive_ptr) in unit_animations

GitHub noreply at github.com
Wed Jun 18 20:04:17 UTC 2014


  Branch: refs/heads/master
  Home:   https://github.com/wesnoth/wesnoth
  Commit: 823d8c2d38c021cda0970fcea60c20b15c4b073d
      https://github.com/wesnoth/wesnoth/commit/823d8c2d38c021cda0970fcea60c20b15c4b073d
  Author: Chris Beck <render787 at gmail.com>
  Date:   2014-06-18 (Wed, 18 Jun 2014)

  Changed paths:
    M src/fake_unit.hpp
    M src/unit.hpp
    M src/unit_animation.cpp
    M src/unit_animation.hpp

  Log Message:
  -----------
  use UnitPtr (intrusive_ptr) in unit_animations

In this commit the unit * in unit_animation is changed to a smart
pointer. This is to prevent the unit_map or some other object
from destroying the unit and creating a dangling pointer
(reported to cause segfaults).

In this commit, we also change the fake_unit class to make sure to
increment the refcounter when the fake_unit is constructed. The
reason is that the fake_unit holder is supposed to own that unit
and let it expire when it goes out of scope. No smart pointer is
supposed to delete it.

This mechanism should possibly be revisited, for example the
fake units could also be held in a reference counted pointer.
With the current system it is still possible that the fake_unit
will go out of scope and be destoryed while the animation is still
alive, this change only prevents smart pointers from destroying it
before it goes out of scope.

I also comment out the reentry_preventer class uses in
unit_animation.cpp, to prevent assertions from happening when I
test for example with the "double debug kill" version of the bug.
The reentry_preventer seems to be unnecessary now.

This addresses bug #18921 and maybe others.


  Commit: bc9de36508338bc665e3658438af9a2f65c6cc12
      https://github.com/wesnoth/wesnoth/commit/bc9de36508338bc665e3658438af9a2f65c6cc12
  Author: Chris Beck <beck.ct at gmail.com>
  Date:   2014-06-18 (Wed, 18 Jun 2014)

  Changed paths:
    M src/fake_unit.hpp
    M src/unit.hpp
    M src/unit_animation.cpp
    M src/unit_animation.hpp

  Log Message:
  -----------
  Merge pull request #209 from cbeck88/reference_counting_in_animations

use UnitPtr (intrusive_ptr) in unit_animations


Compare: https://github.com/wesnoth/wesnoth/compare/45b2db4e24ce...bc9de3650833


More information about the Commits mailing list