From 480d9d10edead569820094db079fc1bc5fbe40ca Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Sun, 4 Dec 2022 16:52:26 +0800 Subject: [PATCH] Fix heap-use-after-free when exiting editor after editing TileSet --- editor/plugins/tiles/tile_set_atlas_source_editor.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp index ae7570e1615..7ed84423bcb 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp @@ -2345,6 +2345,15 @@ void TileSetAtlasSourceEditor::_notification(int p_what) { tile_set_changed_needs_update = false; } } break; + + case NOTIFICATION_EXIT_TREE: { + for (KeyValue &E : tile_data_editors) { + Control *toolbar = E.value->get_toolbar(); + if (toolbar->get_parent() == tool_settings_tile_data_toolbar_container) { + tool_settings_tile_data_toolbar_container->remove_child(toolbar); + } + } + } break; } }