summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Hilbrunner <mhilbrunner@users.noreply.github.com>2021-09-08 01:24:16 +0200
committerGitHub <noreply@github.com>2021-09-08 01:24:16 +0200
commit0d5e13cd805a1aa69c5f395483051d3501bcfcd3 (patch)
tree0a15412f620ac48e17d9c8ccce97095208105b82
parent643ae7063c83b3abd61312d8f99e3b1e438f2658 (diff)
parent37de1df2ab388d4ba21a466231f07f66fe0cc5fd (diff)
Merge pull request #52263 from nekomatata/property_update_all_undo_redo
Fix undo/redo for properties set as PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED
-rw-r--r--editor/editor_inspector.cpp14
-rw-r--r--editor/editor_inspector.h3
2 files changed, 5 insertions, 12 deletions
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index 66f291bd3e..d3841ad6c0 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<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());
diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h
index f6b4303f38..5992c23f8c 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<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);