diff options
| author | Yuri Sizov <11782833+YuriSizov@users.noreply.github.com> | 2023-06-21 11:19:36 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-21 11:19:36 +0200 |
| commit | ebd44641c53ecfafb3fa0bd5f0f6abcbc3a25e05 (patch) | |
| tree | f3a93b604f03592ab13e6636b56ce86d8c5d1d75 | |
| parent | 4fc045e9b53becf063b50a457709ade403235d80 (diff) | |
| parent | c1c5b0a4357a8f84fa29aa199b98af54d4b25537 (diff) | |
| download | redot-engine-ebd44641c53ecfafb3fa0bd5f0f6abcbc3a25e05.tar.gz | |
Merge pull request #78492 from KoBeWi/too_slow
Update indices after removing custom data layers
| -rw-r--r-- | scene/resources/tile_set.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp index 5f19121447..96096afeb4 100644 --- a/scene/resources/tile_set.cpp +++ b/scene/resources/tile_set.cpp @@ -1063,12 +1063,16 @@ void TileSet::move_custom_data_layer(int p_from_index, int p_to_pos) { void TileSet::remove_custom_data_layer(int p_index) { ERR_FAIL_INDEX(p_index, custom_data_layers.size()); custom_data_layers.remove_at(p_index); - for (KeyValue<String, int> E : custom_data_layers_by_name) { + + String to_erase; + for (KeyValue<String, int> &E : custom_data_layers_by_name) { if (E.value == p_index) { - custom_data_layers_by_name.erase(E.key); - break; + to_erase = E.key; + } else if (E.value > p_index) { + E.value--; } } + custom_data_layers_by_name.erase(to_erase); for (KeyValue<int, Ref<TileSetSource>> source : sources) { source.value->remove_custom_data_layer(p_index); |
