Merge pull request #99723 from YeldhamDev/script_favorite_fix

Fix error when favoriting some types of properties
This commit is contained in:
Thaddeus Crews 2024-12-30 08:58:34 -06:00
commit 1e63ed2a5b
No known key found for this signature in database
GPG key ID: 62181B86FE9E5D84

View file

@ -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,46 @@ 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()) {
bool has_prop = ClassDB::has_property(class_name, p_path, true);
if (has_prop) {
StringName validate_name = object->get_class_name();
StringName class_name;
String theme_property;
if (p_path.begins_with("theme_override_")) {
theme_property = p_path.get_slice("/", 1);
}
while (!validate_name.is_empty()) {
class_name = validate_name;
if (!theme_property.is_empty()) { // Deal with theme properties.
bool found = false;
HashMap<String, DocData::ClassDoc>::ConstIterator F = EditorHelp::get_doc_data()->class_list.find(class_name);
if (F) {
for (const DocData::ThemeItemDoc &prop : F->value.theme_properties) {
if (prop.name == theme_property) {
found = true;
break;
}
}
}
if (found) {
break;
}
} else if (ClassDB::has_property(class_name, p_path, true)) { // Check if the property is built-in.
break;
}
class_name = ClassDB::get_parent_class_nocheck(class_name);
validate_name = ClassDB::get_parent_class_nocheck(class_name);
}
// "script" isn't a real property, so a hack is necessary.
if (validate_name.is_empty() && p_path != "script") {
class_name = "";
}
if (class_name.is_empty()) {
// Check if it's part of a script.
Ref<Script> scr = object->get_script();
if (scr.is_valid()) {
List<PropertyInfo> plist;