Update indices after removing custom data layers
This commit is contained in:
parent
329652b6fe
commit
c1c5b0a435
1 changed files with 7 additions and 3 deletions
|
@ -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) {
|
void TileSet::remove_custom_data_layer(int p_index) {
|
||||||
ERR_FAIL_INDEX(p_index, custom_data_layers.size());
|
ERR_FAIL_INDEX(p_index, custom_data_layers.size());
|
||||||
custom_data_layers.remove_at(p_index);
|
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) {
|
if (E.value == p_index) {
|
||||||
custom_data_layers_by_name.erase(E.key);
|
to_erase = E.key;
|
||||||
break;
|
} else if (E.value > p_index) {
|
||||||
|
E.value--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
custom_data_layers_by_name.erase(to_erase);
|
||||||
|
|
||||||
for (KeyValue<int, Ref<TileSetSource>> source : sources) {
|
for (KeyValue<int, Ref<TileSetSource>> source : sources) {
|
||||||
source.value->remove_custom_data_layer(p_index);
|
source.value->remove_custom_data_layer(p_index);
|
||||||
|
|
Loading…
Add table
Reference in a new issue