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 /editor/plugins/animation_tree_editor_plugin.cpp | |
parent | 4aa2c18cb428ffde05c67987926736a9ca62703b (diff) |
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 'editor/plugins/animation_tree_editor_plugin.cpp')
-rw-r--r-- | editor/plugins/animation_tree_editor_plugin.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp index 55975bdefa..9d150150a1 100644 --- a/editor/plugins/animation_tree_editor_plugin.cpp +++ b/editor/plugins/animation_tree_editor_plugin.cpp @@ -281,9 +281,9 @@ void AnimationTreeEditor::_popup_edit_dialog() { case AnimationTreePlayer::NODE_ANIMATION: - if (anim_tree->get_master_player() != NodePath() && anim_tree->has_node(anim_tree->get_master_player()) && anim_tree->get_node(anim_tree->get_master_player())->cast_to<AnimationPlayer>()) { + if (anim_tree->get_master_player() != NodePath() && anim_tree->has_node(anim_tree->get_master_player()) && Object::cast_to<AnimationPlayer>(anim_tree->get_node(anim_tree->get_master_player()))) { - AnimationPlayer *ap = anim_tree->get_node(anim_tree->get_master_player())->cast_to<AnimationPlayer>(); + AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(anim_tree->get_node(anim_tree->get_master_player())); master_anim_popup->clear(); master_anim_popup->add_item("Edit Filters"); master_anim_popup->add_separator(); @@ -1233,7 +1233,7 @@ void AnimationTreeEditor::_edit_filters() { if (np.get_property() != StringName()) { Node *n = base->get_node(np); - Skeleton *s = n->cast_to<Skeleton>(); + Skeleton *s = Object::cast_to<Skeleton>(n); if (s) { String skelbase = E->get().substr(0, E->get().find(":")); @@ -1439,7 +1439,7 @@ AnimationTreeEditor::AnimationTreeEditor() { void AnimationTreeEditorPlugin::edit(Object *p_object) { - anim_tree_editor->edit(p_object->cast_to<AnimationTreePlayer>()); + anim_tree_editor->edit(Object::cast_to<AnimationTreePlayer>(p_object)); } bool AnimationTreeEditorPlugin::handles(Object *p_object) const { |