Merge pull request #52263 from nekomatata/property_update_all_undo_redo

Fix undo/redo for properties set as PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED
This commit is contained in:
Max Hilbrunner 2021-09-08 01:24:16 +02:00 committed by GitHub
commit 0d5e13cd80
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 12 deletions

View file

@ -2843,10 +2843,8 @@ void EditorInspector::update_tree() {
if (ep) {
// Eventually, set other properties/signals after the property editor got added to the tree.
ep->connect("property_changed", callable_mp(this, &EditorInspector::_property_changed));
if (p.usage & PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED) {
ep->connect("property_changed", callable_mp(this, &EditorInspector::_property_changed_update_all), varray(), CONNECT_DEFERRED);
}
bool update_all = (p.usage & PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED);
ep->connect("property_changed", callable_mp(this, &EditorInspector::_property_changed), varray(update_all));
ep->connect("property_keyed", callable_mp(this, &EditorInspector::_property_keyed));
ep->connect("property_deleted", callable_mp(this, &EditorInspector::_property_deleted), varray(), CONNECT_DEFERRED);
ep->connect("property_keyed_with_value", callable_mp(this, &EditorInspector::_property_keyed_with_value));
@ -3175,14 +3173,14 @@ void EditorInspector::_edit_set(const String &p_name, const Variant &p_value, bo
}
}
void EditorInspector::_property_changed(const String &p_path, const Variant &p_value, const String &p_name, bool p_changing) {
void EditorInspector::_property_changed(const String &p_path, const Variant &p_value, const String &p_name, bool p_changing, bool p_update_all) {
// The "changing" variable must be true for properties that trigger events as typing occurs,
// like "text_changed" signal. E.g. text property of Label, Button, RichTextLabel, etc.
if (p_changing) {
this->changing++;
}
_edit_set(p_path, p_value, false, p_name);
_edit_set(p_path, p_value, p_update_all, p_name);
if (p_changing) {
this->changing--;
@ -3193,10 +3191,6 @@ void EditorInspector::_property_changed(const String &p_path, const Variant &p_v
}
}
void EditorInspector::_property_changed_update_all(const String &p_path, const Variant &p_value, const String &p_name, bool p_changing) {
update_tree();
}
void EditorInspector::_multiple_properties_changed(Vector<String> p_paths, Array p_values, bool p_changing) {
ERR_FAIL_COND(p_paths.size() == 0 || p_values.size() == 0);
ERR_FAIL_COND(p_paths.size() != p_values.size());

View file

@ -457,8 +457,7 @@ class EditorInspector : public ScrollContainer {
void _edit_set(const String &p_name, const Variant &p_value, bool p_refresh_all, const String &p_changed_field);
void _property_changed(const String &p_path, const Variant &p_value, const String &p_name = "", bool p_changing = false);
void _property_changed_update_all(const String &p_path, const Variant &p_value, const String &p_name = "", bool p_changing = false);
void _property_changed(const String &p_path, const Variant &p_value, const String &p_name = "", bool p_changing = false, bool p_update_all = false);
void _multiple_properties_changed(Vector<String> p_paths, Array p_values, bool p_changing = false);
void _property_keyed(const String &p_path, bool p_advance);
void _property_keyed_with_value(const String &p_path, const Variant &p_value, bool p_advance);