From cacced7e507f7603bacc03ae2616e58f0ede122a Mon Sep 17 00:00:00 2001 From: Hein-Pieter van Braam Date: Thu, 24 Aug 2017 22:58:51 +0200 Subject: 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/ --- editor/plugins/animation_tree_editor_plugin.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'editor/plugins/animation_tree_editor_plugin.cpp') diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp index 55975bdef..9d150150a 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()) { + if (anim_tree->get_master_player() != NodePath() && anim_tree->has_node(anim_tree->get_master_player()) && Object::cast_to(anim_tree->get_node(anim_tree->get_master_player()))) { - AnimationPlayer *ap = anim_tree->get_node(anim_tree->get_master_player())->cast_to(); + AnimationPlayer *ap = Object::cast_to(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 *s = Object::cast_to(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()); + anim_tree_editor->edit(Object::cast_to(p_object)); } bool AnimationTreeEditorPlugin::handles(Object *p_object) const { -- cgit v1.2.3-70-g09d2