Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ColorPicker committing extra action to history #83786

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions editor/editor_properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2712,16 +2712,6 @@ void EditorPropertyColor::_color_changed(const Color &p_color) {
emit_changed(get_edited_property(), p_color, "", true);
}

void EditorPropertyColor::_popup_closed() {
if (picker->get_pick_color() != last_color) {
emit_changed(get_edited_property(), picker->get_pick_color(), "", false);
}
}

void EditorPropertyColor::_picker_opening() {
last_color = picker->get_pick_color();
}

void EditorPropertyColor::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE:
Expand Down Expand Up @@ -2761,9 +2751,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));
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));
}

////////////// NODE PATH //////////////////////
Expand Down
5 changes: 0 additions & 5 deletions editor/editor_properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -632,11 +632,6 @@ class EditorPropertyColor : public EditorProperty {
GDCLASS(EditorPropertyColor, EditorProperty);
ColorPickerButton *picker = nullptr;
void _color_changed(const Color &p_color);
void _popup_closed();
void _picker_created();
void _picker_opening();

Color last_color;

protected:
virtual void _set_read_only(bool p_read_only) override;
Expand Down
2 changes: 1 addition & 1 deletion scene/gui/color_picker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ void ColorPicker::_html_submitted(const String &p_html) {
color.a = previous_color.a;
}

if (color == previous_color) {
if (color.to_abgr32() == previous_color.to_abgr32()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this check may be too late here. At this point, the internal color state (that's a class member, not a local variable) has already been overwritten with the return value of Color::from_string, so this only skips the change notification, doesn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, you're right.

return;
}
if (!is_inside_tree()) {
Expand Down
Loading