Skip to content

Commit a7146ef

Browse files
committed
Merge pull request #101570 from larspet/color-picker-pickle
Don't instantiate `ColorPicker` in `EditorPropertyColor` constructor
2 parents b5737f8 + 3376ba6 commit a7146ef

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

editor/editor_properties.cpp

+12-8
Original file line numberDiff line numberDiff line change
@@ -2599,18 +2599,24 @@ void EditorPropertyColor::_color_changed(const Color &p_color) {
25992599
get_edited_object()->set(get_edited_property(), p_color);
26002600
}
26012601

2602+
void EditorPropertyColor::_picker_created() {
2603+
picker->get_popup()->connect("about_to_popup", callable_mp(this, &EditorPropertyColor::_popup_opening));
2604+
picker->connect("popup_closed", callable_mp(this, &EditorPropertyColor::_popup_closed), CONNECT_DEFERRED);
2605+
}
2606+
2607+
void EditorPropertyColor::_popup_opening() {
2608+
EditorNode::get_singleton()->setup_color_picker(picker->get_picker());
2609+
last_color = picker->get_pick_color();
2610+
was_checked = !is_checkable() || is_checked();
2611+
}
2612+
26022613
void EditorPropertyColor::_popup_closed() {
26032614
get_edited_object()->set(get_edited_property(), was_checked ? Variant(last_color) : Variant());
26042615
if (!picker->get_pick_color().is_equal_approx(last_color)) {
26052616
emit_changed(get_edited_property(), picker->get_pick_color(), "", false);
26062617
}
26072618
}
26082619

2609-
void EditorPropertyColor::_picker_opening() {
2610-
last_color = picker->get_pick_color();
2611-
was_checked = !is_checkable() || is_checked();
2612-
}
2613-
26142620
void EditorPropertyColor::_notification(int p_what) {
26152621
switch (p_what) {
26162622
case NOTIFICATION_ENTER_TREE:
@@ -2654,9 +2660,7 @@ EditorPropertyColor::EditorPropertyColor() {
26542660
add_child(picker);
26552661
picker->set_flat(true);
26562662
picker->connect("color_changed", callable_mp(this, &EditorPropertyColor::_color_changed));
2657-
picker->connect("popup_closed", callable_mp(this, &EditorPropertyColor::_popup_closed), CONNECT_DEFERRED);
2658-
picker->get_popup()->connect("about_to_popup", callable_mp(EditorNode::get_singleton(), &EditorNode::setup_color_picker).bind(picker->get_picker()));
2659-
picker->get_popup()->connect("about_to_popup", callable_mp(this, &EditorPropertyColor::_picker_opening));
2663+
picker->connect("picker_created", callable_mp(this, &EditorPropertyColor::_picker_created), CONNECT_ONE_SHOT);
26602664
}
26612665

26622666
////////////// NODE PATH //////////////////////

editor/editor_properties.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -593,8 +593,9 @@ class EditorPropertyColor : public EditorProperty {
593593
GDCLASS(EditorPropertyColor, EditorProperty);
594594
ColorPickerButton *picker = nullptr;
595595
void _color_changed(const Color &p_color);
596+
void _picker_created();
597+
void _popup_opening();
596598
void _popup_closed();
597-
void _picker_opening();
598599

599600
Color last_color;
600601
bool live_changes_enabled = true;

0 commit comments

Comments
 (0)