From 37de1df2ab388d4ba21a466231f07f66fe0cc5fd Mon Sep 17 00:00:00 2001 From: PouleyKetchoupp Date: Mon, 30 Aug 2021 09:59:45 -0700 Subject: [PATCH] Fix undo/redo for properties set as PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED Full inspector update was triggered only on property changed, but not on undo/redo actions, which can cause inspector discrepancies when some properties are supposed to be shown or hidden. Now update all flag is passed into _edit_set() method which already has logic to handle this case properly (it still triggers update_tree() down the line). --- editor/editor_inspector.cpp | 14 ++++---------- editor/editor_inspector.h | 3 +-- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 66f291bd3e2..d3841ad6c07 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -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 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()); diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h index f6b4303f38b..5992c23f8c4 100644 --- a/editor/editor_inspector.h +++ b/editor/editor_inspector.h @@ -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 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);