diff options
author | Hein-Pieter van Braam <hp@tmm.cx> | 2017-08-24 22:58:51 +0200 |
---|---|---|
committer | Hein-Pieter van Braam <hp@tmm.cx> | 2017-08-24 23:08:24 +0200 |
commit | cacced7e507f7603bacc03ae2616e58f0ede122a (patch) | |
tree | 7af89373e86cd1a7af6ea04e10280084cabb7144 /scene/animation/animation_tree_player.cpp | |
parent | 4aa2c18cb428ffde05c67987926736a9ca62703b (diff) | |
download | redot-engine-cacced7e507f7603bacc03ae2616e58f0ede122a.tar.gz |
Convert Object::cast_to() to the static version
Currently we rely on some undefined behavior when Object->cast_to() gets
called with a Null pointer. This used to work fine with GCC < 6 but
newer versions of GCC remove all codepaths in which the this pointer is
Null. However, the non-static cast_to() was supposed to be null safe.
This patch makes cast_to() Null safe and removes the now redundant Null
checks where they existed.
It is explained in this article: https://www.viva64.com/en/b/0226/
Diffstat (limited to 'scene/animation/animation_tree_player.cpp')
-rw-r--r-- | scene/animation/animation_tree_player.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/scene/animation/animation_tree_player.cpp b/scene/animation/animation_tree_player.cpp index fd8b33e666..1c4a66a607 100644 --- a/scene/animation/animation_tree_player.cpp +++ b/scene/animation/animation_tree_player.cpp @@ -1487,8 +1487,8 @@ AnimationTreePlayer::Track *AnimationTreePlayer::_find_track(const NodePath &p_p if (p_path.get_property()) { - if (child->cast_to<Skeleton>()) - bone_idx = child->cast_to<Skeleton>()->find_bone(p_path.get_property()); + if (Object::cast_to<Skeleton>(child)) + bone_idx = Object::cast_to<Skeleton>(child)->find_bone(p_path.get_property()); if (bone_idx == -1) property = p_path.get_property(); } @@ -1503,8 +1503,8 @@ AnimationTreePlayer::Track *AnimationTreePlayer::_find_track(const NodePath &p_p Track tr; tr.id = id; tr.object = resource.is_valid() ? (Object *)resource.ptr() : (Object *)child; - tr.skeleton = child->cast_to<Skeleton>(); - tr.spatial = child->cast_to<Spatial>(); + tr.skeleton = Object::cast_to<Skeleton>(child); + tr.spatial = Object::cast_to<Spatial>(child); tr.bone_idx = bone_idx; tr.property = property; @@ -1644,7 +1644,7 @@ void AnimationTreePlayer::_update_sources() { ERR_FAIL_COND(!m); } - AnimationPlayer *ap = m->cast_to<AnimationPlayer>(); + AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(m); if (!ap) { |