Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error when favoriting some types of properties #99723

Merged
merged 1 commit into from
Dec 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 42 additions & 12 deletions editor/editor_inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)) {
Expand Down Expand Up @@ -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;
Expand Down