Skip to content

Commit

Permalink
Fix theme_override tooltip caching
Browse files Browse the repository at this point in the history
theme_override properties have some special handling in EditorInspector.  When caching documentation info for properties, the theme_item_name value (used only for theme_overrides) was not being cached, so it would only be included on first use.  This meant that theme_override property tooltips would show up in the editor the first time a node was selected, but not again after selecting something else/reselecting.  Added theme_item_name to caching to fix this.

Fixes godotengine#90395
  • Loading branch information
aaronp64 authored and divshekhar committed Apr 23, 2024
1 parent 5af65e6 commit 3dca1f0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
22 changes: 11 additions & 11 deletions editor/editor_inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3220,12 +3220,13 @@ void EditorInspector::update_tree() {
}

// Search for the doc path in the cache.
HashMap<StringName, HashMap<StringName, String>>::Iterator E = doc_path_cache.find(classname);
HashMap<StringName, HashMap<StringName, DocCacheInfo>>::Iterator E = doc_cache.find(classname);
if (E) {
HashMap<StringName, String>::Iterator F = E->value.find(propname);
HashMap<StringName, DocCacheInfo>::Iterator F = E->value.find(propname);
if (F) {
found = true;
doc_path = F->value;
doc_path = F->value.doc_path;
theme_item_name = F->value.theme_item_name;
}
}

Expand All @@ -3246,23 +3247,22 @@ void EditorInspector::update_tree() {
theme_item_name = F->value.theme_properties[i].name;
}
}

if (is_native_class) {
doc_path_cache[classname][propname] = doc_path;
}
} else {
for (int i = 0; i < F->value.properties.size(); i++) {
String doc_path_current = "class_property:" + F->value.name + ":" + F->value.properties[i].name;
if (F->value.properties[i].name == propname.operator String()) {
doc_path = doc_path_current;
}

if (is_native_class) {
doc_path_cache[classname][propname] = doc_path;
}
}
}

if (is_native_class) {
DocCacheInfo cache_info;
cache_info.doc_path = doc_path;
cache_info.theme_item_name = theme_item_name;
doc_cache[classname][propname] = cache_info;
}

if (!doc_path.is_empty() || F->value.inherits.is_empty()) {
break;
}
Expand Down
7 changes: 6 additions & 1 deletion editor/editor_inspector.h
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,12 @@ class EditorInspector : public ScrollContainer {
int property_focusable;
int update_scroll_request;

HashMap<StringName, HashMap<StringName, String>> doc_path_cache;
struct DocCacheInfo {
String doc_path;
String theme_item_name;
};

HashMap<StringName, HashMap<StringName, DocCacheInfo>> doc_cache;
HashSet<StringName> restart_request_props;
HashMap<String, String> custom_property_descriptions;

Expand Down

0 comments on commit 3dca1f0

Please sign in to comment.