From 5afe312da06eef3740639fc143c6594b93350072 Mon Sep 17 00:00:00 2001 From: Michael Alexsander Date: Tue, 26 Nov 2024 18:26:35 -0300 Subject: [PATCH] Fix error when favoriting some types of properties --- editor/editor_inspector.cpp | 41 ++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 4e2e44574052..9fb91c8332c7 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -3536,13 +3536,6 @@ void EditorInspector::update_tree() { } } - ep->set_draw_warning(draw_warning); - ep->set_use_folding(use_folding); - ep->set_favoritable(can_favorite && !disable_favorite); - ep->set_checkable(checkable); - ep->set_checked(checked); - ep->set_keying(keying); - ep->set_read_only(property_read_only || all_read_only); if (p.name.begins_with("metadata/")) { Variant _default = Variant(); if (node != nullptr) { @@ -3552,6 +3545,14 @@ void EditorInspector::update_tree() { } else { ep->set_deletable(deletable_properties); } + + ep->set_draw_warning(draw_warning); + ep->set_use_folding(use_folding); + ep->set_favoritable(can_favorite && !disable_favorite && !ep->is_deletable()); + ep->set_checkable(checkable); + ep->set_checked(checked); + ep->set_keying(keying); + ep->set_read_only(property_read_only || all_read_only); } if (ep && ep->is_favoritable() && current_favorites.has(p.name)) { @@ -4351,17 +4352,37 @@ void EditorInspector::_set_property_favorited(const String &p_path, bool p_favor return; } - StringName class_name = object->get_class_name(); - while (!class_name.is_empty()) { + StringName validate_name = object->get_class_name(); + StringName class_name; + // Check if the property is built-in. + while (!validate_name.is_empty()) { + class_name = validate_name; + bool has_prop = ClassDB::has_property(class_name, p_path, true); if (has_prop) { break; } - class_name = ClassDB::get_parent_class_nocheck(class_name); + validate_name = ClassDB::get_parent_class_nocheck(class_name); + } + + if (validate_name.is_empty()) { + // "script" isn't a real property, so a hack is necessary. + if (p_path != "script") { + class_name = ""; + } + + // Deal with theme properties. + if (p_path.begins_with("theme_override_")) { + const String slice = p_path.get_slice("/", 1); + if (!slice.is_empty()) { + class_name = slice; + } + } } if (class_name.is_empty()) { + // Check if it's part of a script. Ref