From e75e104e2d23d21e67c38053d1a523073adb1f6d Mon Sep 17 00:00:00 2001 From: "ocean (they/them)" Date: Thu, 29 Jun 2023 16:03:21 +0200 Subject: [PATCH] Fix adding colors to swatches not updating in previous ColorPickers. ColorPicker was only updating colors if its swatches were empty. It should always update from the cache in case some other ColorPicker updated the swatch cache. (cherry picked from commit a132ed0ca49de6e2e7e202c3dce8e6a21d9282c0) --- scene/gui/color_picker.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index cea60f375a4..c6abd5c8b85 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -561,13 +561,14 @@ void ColorPicker::_update_presets() { #ifdef TOOLS_ENABLED if (editor_settings) { - // Only load preset buttons when the only child is the add-preset button. - if (preset_container->get_child_count() == 1) { - for (int i = 0; i < preset_cache.size(); i++) { - _add_preset_button(preset_size, preset_cache[i]); - } - _notification(NOTIFICATION_VISIBILITY_CHANGED); + // Rebuild swatch color buttons, keeping the add-preset button in the first position. + for (int i = 1; i < preset_container->get_child_count(); i++) { + preset_container->get_child(i)->queue_free(); } + for (int i = 0; i < preset_cache.size(); i++) { + _add_preset_button(preset_size, preset_cache[i]); + } + _notification(NOTIFICATION_VISIBILITY_CHANGED); } #endif }