summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorJuande <juande@gmail.com>2017-12-04 14:17:58 +0100
committerJuande <juande@gmail.com>2017-12-04 14:17:58 +0100
commit0a5cf37a759be03041df4de6c0420809f4440d6b (patch)
tree1cb1c1a22ac24c42ec118c80785354461fc719e0 /editor
parent055c5600c8877ebe44c80fa853cca4b6b553eb0a (diff)
Fix the revert button issue with instanced nodes
The method "check_reload_status" on the file "property_editor.cpp" didn't take into account if the field is a property of an instanced node just like the "update_tree" does. The code that checks this in "update_tree" has been extracted into the method "_is_instanced_node_with_original_property_different" to be also used in "check_reload_status". Fixes #13415
Diffstat (limited to 'editor')
-rw-r--r--editor/property_editor.cpp40
-rw-r--r--editor/property_editor.h1
2 files changed, 26 insertions, 15 deletions
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp
index 6f9454be2c..25ba02cf63 100644
--- a/editor/property_editor.cpp
+++ b/editor/property_editor.cpp
@@ -2101,6 +2101,23 @@ bool PropertyEditor::_is_property_different(const Variant &p_current, const Vari
return bool(Variant::evaluate(Variant::OP_NOT_EQUAL, p_current, p_orig));
}
+bool PropertyEditor::_is_instanced_node_with_original_property_different(const String &p_name, TreeItem *item) {
+ bool mbi = _might_be_in_instance();
+ if (mbi) {
+ Variant vorig;
+ Dictionary d = item->get_metadata(0);
+ int usage = d.has("usage") ? int(int(d["usage"]) & (PROPERTY_USAGE_STORE_IF_NONONE | PROPERTY_USAGE_STORE_IF_NONZERO)) : 0;
+ if (_get_instanced_node_original_property(p_name, vorig) || usage) {
+ Variant v = obj->get(p_name);
+
+ if (_is_property_different(v, vorig, usage)) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
TreeItem *PropertyEditor::find_item(TreeItem *p_item, const String &p_name) {
if (!p_item)
@@ -2360,6 +2377,10 @@ void PropertyEditor::_check_reload_status(const String &p_name, TreeItem *item)
}
}
+ if (_is_instanced_node_with_original_property_different(p_name, item)) {
+ has_reload = true;
+ }
+
if (obj->call("property_can_revert", p_name).operator bool()) {
has_reload = true;
@@ -3512,20 +3533,9 @@ void PropertyEditor::update_tree() {
bool has_reload = false;
- bool mbi = _might_be_in_instance();
- if (mbi) {
-
- Variant vorig;
- Dictionary d = item->get_metadata(0);
- int usage = d.has("usage") ? int(int(d["usage"]) & (PROPERTY_USAGE_STORE_IF_NONONE | PROPERTY_USAGE_STORE_IF_NONZERO)) : 0;
- if (_get_instanced_node_original_property(p.name, vorig) || usage) {
- Variant v = obj->get(p.name);
-
- if (_is_property_different(v, vorig, usage)) {
- item->add_button(1, get_icon("ReloadSmall", "EditorIcons"), 3);
- has_reload = true;
- }
- }
+ if (_is_instanced_node_with_original_property_different(p.name, item)) {
+ item->add_button(1, get_icon("ReloadSmall", "EditorIcons"), 3);
+ has_reload = true;
}
if (obj->call("property_can_revert", p.name).operator bool()) {
@@ -3545,7 +3555,7 @@ void PropertyEditor::update_tree() {
}
}
- if (mbi && !has_reload && item->get_cell_mode(1) == TreeItem::CELL_MODE_RANGE && item->get_text(1) == String()) {
+ if (_might_be_in_instance() && !has_reload && item->get_cell_mode(1) == TreeItem::CELL_MODE_RANGE && item->get_text(1) == String()) {
item->add_button(1, get_icon("ReloadEmpty", "EditorIcons"), 3, true);
}
}
diff --git a/editor/property_editor.h b/editor/property_editor.h
index a337a05e46..d849919bed 100644
--- a/editor/property_editor.h
+++ b/editor/property_editor.h
@@ -253,6 +253,7 @@ class PropertyEditor : public Control {
bool _might_be_in_instance();
bool _get_instanced_node_original_property(const StringName &p_prop, Variant &value);
bool _is_property_different(const Variant &p_current, const Variant &p_orig, int p_usage = 0);
+ bool _is_instanced_node_with_original_property_different(const String &p_name, TreeItem *item);
void _refresh_item(TreeItem *p_item);
void _set_range_def(Object *p_item, String prop, float p_frame);