Repository: godotengine/godot (language: cpp)

Issue:
Inspector loads slowly when there's many Color properties
### Tested versions

Reproducible in 4.4.dev7, and probably many versions earlier.

### System information

Windows 11

### Issue description

Inspectors (or project/editor settings) that contain many Color properties will load slowly. Additionally, they can be slow to switch away from.

### Steps to reproduce

For example, check out:
```
Editor Settings > Text Editor > Theme     (the worst example)
Editor Settings > Editors > 3D Gizmos
Editor Settings > Editors > Visual Editors
Project Settings > Debug > Shapes
```



### Minimal reproduction project (MRP)

Also, I made an MPR that has a Node with an exported `Array[Color]`, and some extra Color properties. Try repeatedly switching between the `Colorful` and `Colorless` nodes (make sure the Array is expanded).

[color_picker.zip](https://github.com/user-attachments/files/18418402/color_picker.zip)


Discussion / hints:

Fix patch:
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 69b44a3e8f88..b1a4bb76f325 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -2599,6 +2599,17 @@ void EditorPropertyColor::_color_changed(const Color &p_color) {
 	get_edited_object()->set(get_edited_property(), p_color);
 }
 
+void EditorPropertyColor::_picker_created() {
+	picker->get_popup()->connect("about_to_popup", callable_mp(this, &EditorPropertyColor::_popup_opening));
+	picker->connect("popup_closed", callable_mp(this, &EditorPropertyColor::_popup_closed), CONNECT_DEFERRED);
+}
+
+void EditorPropertyColor::_popup_opening() {
+	EditorNode::get_singleton()->setup_color_picker(picker->get_picker());
+	last_color = picker->get_pick_color();
+	was_checked = !is_checkable() || is_checked();
+}
+
 void EditorPropertyColor::_popup_closed() {
 	get_edited_object()->set(get_edited_property(), was_checked ? Variant(last_color) : Variant());
 	if (!picker->get_pick_color().is_equal_approx(last_color)) {
@@ -2606,11 +2617,6 @@ void EditorPropertyColor::_popup_closed() {
 	}
 }
 
-void EditorPropertyColor::_picker_opening() {
-	last_color = picker->get_pick_color();
-	was_checked = !is_checkable() || is_checked();
-}
-
 void EditorPropertyColor::_notification(int p_what) {
 	switch (p_what) {
 		case NOTIFICATION_ENTER_TREE:
@@ -2654,9 +2660,7 @@ EditorPropertyColor::EditorPropertyColor() {
 	add_child(picker);
 	picker->set_flat(true);
 	picker->connect("color_changed", callable_mp(this, &EditorPropertyColor::_color_changed));
-	picker->connect("popup_closed", callable_mp(this, &EditorPropertyColor::_popup_closed), CONNECT_DEFERRED);
-	picker->get_popup()->connect("about_to_popup", callable_mp(EditorNode::get_singleton(), &EditorNode::setup_color_picker).bind(picker->get_picker()));
-	picker->get_popup()->connect("about_to_popup", callable_mp(this, &EditorPropertyColor::_picker_opening));
+	picker->connect("picker_created", callable_mp(this, &EditorPropertyColor::_picker_created), CONNECT_ONE_SHOT);
 }
 
 ////////////// NODE PATH //////////////////////
diff --git a/editor/editor_properties.h b/editor/editor_properties.h
index bcdae5342d28..6fe8cc3c3f38 100644
--- a/editor/editor_properties.h
+++ b/editor/editor_properties.h
@@ -593,8 +593,9 @@ class EditorPropertyColor : public EditorProperty {
 	GDCLASS(EditorPropertyColor, EditorProperty);
 	ColorPickerButton *picker = nullptr;
 	void _color_changed(const Color &p_color);
+	void _picker_created();
+	void _popup_opening();
 	void _popup_closed();
-	void _picker_opening();
 
 	Color last_color;
 	bool live_changes_enabled = true;


Test patch: