1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Fix game crashes when adding color preset after clearing presets in another control

This commit is contained in:
Konrad Gadzina
2025-03-16 10:36:01 +01:00
parent fde0616a0e
commit d51f33e1b4

View File

@@ -1138,16 +1138,21 @@ void ColorPicker::add_preset(const Color &p_color) {
List<Color>::Element *e = presets.find(p_color);
if (e) {
presets.move_to_back(e);
preset_cache.move_to_back(preset_cache.find(p_color));
preset_container->move_child(preset_group->get_pressed_button(), preset_container->get_child_count() - 1);
} else {
presets.push_back(p_color);
preset_cache.push_back(p_color);
_add_preset_button(_get_preset_size(), p_color);
}
List<Color>::Element *cache_e = preset_cache.find(p_color);
if (cache_e) {
preset_cache.move_to_back(cache_e);
} else {
preset_cache.push_back(p_color);
}
if (!palette_name->get_text().is_empty()) {
palette_name->set_text(vformat("%s*", palette_name->get_text().trim_suffix("*")));
palette_name->set_tooltip_text(ETR("The changes to this palette have not been saved to a file."));