You've already forked godot
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:
@@ -1138,16 +1138,21 @@ void ColorPicker::add_preset(const Color &p_color) {
|
|||||||
List<Color>::Element *e = presets.find(p_color);
|
List<Color>::Element *e = presets.find(p_color);
|
||||||
if (e) {
|
if (e) {
|
||||||
presets.move_to_back(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);
|
preset_container->move_child(preset_group->get_pressed_button(), preset_container->get_child_count() - 1);
|
||||||
} else {
|
} else {
|
||||||
presets.push_back(p_color);
|
presets.push_back(p_color);
|
||||||
preset_cache.push_back(p_color);
|
|
||||||
|
|
||||||
_add_preset_button(_get_preset_size(), 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()) {
|
if (!palette_name->get_text().is_empty()) {
|
||||||
palette_name->set_text(vformat("%s*", palette_name->get_text().trim_suffix("*")));
|
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."));
|
palette_name->set_tooltip_text(ETR("The changes to this palette have not been saved to a file."));
|
||||||
|
|||||||
Reference in New Issue
Block a user