From d0f99ec3d3c379ea05b6e26162ebdb72d0e12cff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Sun, 25 May 2025 14:06:57 +0200 Subject: [PATCH] TileSet: Fix potential crash updating stale atlas source editor toolbar --- editor/plugins/tiles/tile_set_atlas_source_editor.cpp | 7 +++++-- editor/plugins/tiles/tile_set_atlas_source_editor.h | 1 - 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp index 419cc35d7b8..c8612f15e35 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp @@ -894,10 +894,9 @@ void TileSetAtlasSourceEditor::_update_current_tile_data_editor() { // Get the correct editor for the TileData's property. if (current_tile_data_editor) { - current_tile_data_editor_toolbar = current_tile_data_editor->get_toolbar(); current_property = property; current_tile_data_editor->set_visible(tools_button_group->get_pressed_button() == tool_paint_button); - current_tile_data_editor_toolbar->set_visible(tools_button_group->get_pressed_button() == tool_paint_button); + current_tile_data_editor->get_toolbar()->set_visible(tools_button_group->get_pressed_button() == tool_paint_button); } } @@ -1031,6 +1030,10 @@ void TileSetAtlasSourceEditor::_update_atlas_view() { void TileSetAtlasSourceEditor::_update_toolbar() { // Show the tools and settings. + Control *current_tile_data_editor_toolbar = nullptr; + if (current_tile_data_editor) { + current_tile_data_editor_toolbar = current_tile_data_editor->get_toolbar(); + } if (tools_button_group->get_pressed_button() == tool_setup_atlas_source_button) { if (current_tile_data_editor_toolbar) { current_tile_data_editor_toolbar->hide(); diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.h b/editor/plugins/tiles/tile_set_atlas_source_editor.h index bb0c5e04703..2407e287b43 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.h +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.h @@ -142,7 +142,6 @@ private: // -- Tile data editors -- String current_property; - Control *current_tile_data_editor_toolbar = nullptr; HashMap tile_data_editors; TileDataEditor *current_tile_data_editor = nullptr; void _tile_data_editors_tree_selected();