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/tile_map_editor_plugin.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'editor/plugins/tile_map_editor_plugin.cpp') diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp index 80ff6627b..d89fe43ed 100644 --- a/editor/plugins/tile_map_editor_plugin.cpp +++ b/editor/plugins/tile_map_editor_plugin.cpp @@ -1329,7 +1329,7 @@ void TileMapEditor::edit(Node *p_tile_map) { node->disconnect("settings_changed", this, "_tileset_settings_changed"); if (p_tile_map) { - node = p_tile_map->cast_to(); + node = Object::cast_to(p_tile_map); if (!canvas_item_editor->is_connected("draw", this, "_canvas_draw")) canvas_item_editor->connect("draw", this, "_canvas_draw"); if (!canvas_item_editor->is_connected("mouse_entered", this, "_canvas_mouse_enter")) @@ -1407,7 +1407,7 @@ TileMapEditor::CellOp TileMapEditor::_get_op_from_cell(const Point2i &p_pos) { void TileMapEditor::_update_transform_buttons(Object *p_button) { //ERR_FAIL_NULL(p_button); - ToolButton *b = p_button->cast_to(); + ToolButton *b = Object::cast_to(p_button); //ERR_FAIL_COND(!b); if (b == rotate_0) { @@ -1582,7 +1582,7 @@ TileMapEditor::~TileMapEditor() { void TileMapEditorPlugin::edit(Object *p_object) { - tile_map_editor->edit(p_object->cast_to()); + tile_map_editor->edit(Object::cast_to(p_object)); } bool TileMapEditorPlugin::handles(Object *p_object) const { -- cgit v1.2.3-70-g09d2