Skip to content

Commit

Permalink
Fix error when favoriting some types of properties
Browse files Browse the repository at this point in the history
  • Loading branch information
YeldhamDev committed Dec 28, 2024
1 parent 75ce426 commit 5afe312
Showing 1 changed file with 31 additions and 10 deletions.
41 changes: 31 additions & 10 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,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<Script> scr = object->get_script();
if (scr.is_valid()) {
List<PropertyInfo> plist;
Expand Down

0 comments on commit 5afe312

Please sign in to comment.