From b808923b5412cfe7e5f8791f81e4c40dcaf320bd Mon Sep 17 00:00:00 2001 From: Michael Alexsander Date: Tue, 9 Aug 2022 19:04:40 -0300 Subject: [PATCH] Fix error when switching to another `GridMap` with an item with higher index selected (cherry picked from commit fe16aecbacaef37b8a56de34c9cb5a69f7a26644) --- modules/gridmap/grid_map_editor_plugin.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index 77818d737d4..20bcefbe573 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -904,10 +904,12 @@ void GridMapEditor::update_palette() { } if (selected != -1 && mesh_library_palette->get_item_count() > 0) { - mesh_library_palette->select(selected); + // Make sure that this variable is set correctly. + selected_palette = MIN(selected, mesh_library_palette->get_item_count() - 1); + mesh_library_palette->select(selected_palette); } - last_mesh_library = mesh_library.operator->(); + last_mesh_library = *mesh_library; } void GridMapEditor::edit(GridMap *p_gridmap) {