From 7f63b0e8cdc0ef2369d3b623c5943e2b6cd1b1ae Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Fri, 22 Feb 2019 17:42:29 -0300 Subject: [PATCH] Added a workaround to avoid crashes due to how TileSet editor works, fixes #23672 Also fixed a few uninitialized memory variables. --- editor/editor_node.cpp | 4 ++++ editor/editor_node.h | 1 + editor/editor_properties.cpp | 2 +- editor/plugins/item_list_editor_plugin.cpp | 1 + editor/plugins/tile_set_editor_plugin.cpp | 1 + scene/main/viewport.cpp | 2 ++ 6 files changed, 10 insertions(+), 1 deletion(-) diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 538b3f02bd6..8c9974404e9 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -1370,6 +1370,9 @@ bool EditorNode::item_has_editor(Object *p_object) { return editor_data.get_subeditors(p_object).size() > 0; } +void EditorNode::edit_item_resource(RES p_resource) { + edit_item(p_resource.ptr()); +} void EditorNode::edit_item(Object *p_object) { Vector sub_plugins; @@ -4730,6 +4733,7 @@ void EditorNode::_bind_methods() { ClassDB::bind_method("_clear_undo_history", &EditorNode::_clear_undo_history); ClassDB::bind_method("_dropped_files", &EditorNode::_dropped_files); ClassDB::bind_method("_toggle_distraction_free_mode", &EditorNode::_toggle_distraction_free_mode); + ClassDB::bind_method("edit_item_resource", &EditorNode::edit_item_resource); ClassDB::bind_method(D_METHOD("get_gui_base"), &EditorNode::get_gui_base); ClassDB::bind_method(D_METHOD("_bottom_panel_switch"), &EditorNode::_bottom_panel_switch); diff --git a/editor/editor_node.h b/editor/editor_node.h index 077704ca05f..46a65b56fa8 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -673,6 +673,7 @@ public: void push_item(Object *p_object, const String &p_property = "", bool p_inspector_only = false); void edit_item(Object *p_object); + void edit_item_resource(RES p_resource); bool item_has_editor(Object *p_object); void open_request(const String &p_path); diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 08e4260deb5..a07cffb0787 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -2439,7 +2439,7 @@ void EditorPropertyResource::_button_input(const Ref &p_event) { void EditorPropertyResource::_open_editor_pressed() { RES res = get_edited_object()->get(get_edited_property()); if (res.is_valid()) { - EditorNode::get_singleton()->edit_item(res.ptr()); + EditorNode::get_singleton()->call_deferred("edit_item_resource", res); //may clear the editor so do it deferred } } diff --git a/editor/plugins/item_list_editor_plugin.cpp b/editor/plugins/item_list_editor_plugin.cpp index db0816064ce..b3f3ccf5013 100644 --- a/editor/plugins/item_list_editor_plugin.cpp +++ b/editor/plugins/item_list_editor_plugin.cpp @@ -353,6 +353,7 @@ void ItemListEditor::_bind_methods() { ItemListEditor::ItemListEditor() { selected_idx = -1; + item_list = NULL; toolbar_button = memnew(ToolButton); toolbar_button->set_text(TTR("Items")); diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp index 36fe1af33f1..26f8b748621 100644 --- a/editor/plugins/tile_set_editor_plugin.cpp +++ b/editor/plugins/tile_set_editor_plugin.cpp @@ -2705,6 +2705,7 @@ void TilesetEditorContext::_bind_methods() { TilesetEditorContext::TilesetEditorContext(TileSetEditor *p_tileset_editor) { tileset_editor = p_tileset_editor; + snap_options_visible = false; } void TileSetEditorPlugin::edit(Object *p_node) { diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 31b73100b93..090e6bdcb0a 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -3202,6 +3202,8 @@ Viewport::Viewport() { gui.drag_attempted = false; gui.canvas_sort_index = 0; gui.roots_order_dirty = false; + gui.mouse_focus = NULL; + gui.last_mouse_focus = NULL; msaa = MSAA_DISABLED; hdr = true;