summaryrefslogtreecommitdiffstats
path: root/editor/connections_dialog.cpp
diff options
context:
space:
mode:
authorDanil Alexeev <danil@alexeev.xyz>2023-08-17 17:44:02 +0300
committerDanil Alexeev <danil@alexeev.xyz>2023-08-17 18:59:37 +0300
commitfe5bcadb73103b46ee9714c4a00a93fe683a8932 (patch)
treef0d18beee361ccaba5ba07236ed6179dd9f1ece2 /editor/connections_dialog.cpp
parent0511f9d9a7d56c742d87fafdcea8785d40ad14b3 (diff)
downloadredot-engine-fe5bcadb73103b46ee9714c4a00a93fe683a8932.tar.gz
Editor: Don't cache script signal descriptions
Diffstat (limited to 'editor/connections_dialog.cpp')
-rw-r--r--editor/connections_dialog.cpp57
1 files changed, 24 insertions, 33 deletions
diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp
index d4aebfc7a6..5ac1a11c02 100644
--- a/editor/connections_dialog.cpp
+++ b/editor/connections_dialog.cpp
@@ -1250,28 +1250,28 @@ void ConnectionsDock::update_tree() {
String doc_class_name;
Ref<Texture2D> class_icon;
List<MethodInfo> class_signals;
- const DocData::ClassDoc *class_doc = nullptr;
if (script_base.is_valid()) {
- // Try script global name.
class_name = script_base->get_global_name();
- if (!class_name.is_empty()) {
- HashMap<String, DocData::ClassDoc>::ConstIterator F = doc_data->class_list.find(class_name);
- if (F) {
- class_doc = &F->value;
- doc_class_name = class_name;
- }
- }
-
- // Try script path.
if (class_name.is_empty()) {
class_name = script_base->get_path().get_file();
}
- if (!class_doc) {
+
+ doc_class_name = script_base->get_global_name();
+ if (doc_class_name.is_empty()) {
doc_class_name = script_base->get_path().trim_prefix("res://").quote();
+ }
+
+ // For a script class, the cache is filled each time.
+ if (!doc_class_name.is_empty()) {
+ if (descr_cache.has(doc_class_name)) {
+ descr_cache[doc_class_name].clear();
+ }
HashMap<String, DocData::ClassDoc>::ConstIterator F = doc_data->class_list.find(doc_class_name);
if (F) {
- class_doc = &F->value;
+ for (int i = 0; i < F->value.signals.size(); i++) {
+ descr_cache[doc_class_name][F->value.signals[i].name] = F->value.signals[i].description;
+ }
}
}
@@ -1301,6 +1301,17 @@ void ConnectionsDock::update_tree() {
script_base = base;
} else {
class_name = native_base;
+ doc_class_name = class_name;
+
+ // For a native class, the cache is filled once.
+ if (!descr_cache.has(doc_class_name)) {
+ HashMap<String, DocData::ClassDoc>::ConstIterator F = doc_data->class_list.find(doc_class_name);
+ if (F) {
+ for (int i = 0; i < F->value.signals.size(); i++) {
+ descr_cache[doc_class_name][F->value.signals[i].name] = DTR(F->value.signals[i].description);
+ }
+ }
+ }
if (has_theme_icon(native_base, SNAME("EditorIcons"))) {
class_icon = get_theme_icon(native_base, SNAME("EditorIcons"));
@@ -1308,12 +1319,6 @@ void ConnectionsDock::update_tree() {
ClassDB::get_signal_list(native_base, &class_signals, true);
- HashMap<String, DocData::ClassDoc>::ConstIterator F = doc_data->class_list.find(class_name);
- if (F) {
- class_doc = &F->value;
- doc_class_name = class_name;
- }
-
native_base = ClassDB::get_parent_class(native_base);
}
@@ -1361,29 +1366,15 @@ void ConnectionsDock::update_tree() {
// Set tooltip with the signal's documentation.
{
String descr;
- bool found = false;
HashMap<StringName, HashMap<StringName, String>>::ConstIterator G = descr_cache.find(doc_class_name);
if (G) {
HashMap<StringName, String>::ConstIterator F = G->value.find(signal_name);
if (F) {
- found = true;
descr = F->value;
}
}
- if (!found) {
- if (class_doc) {
- for (int i = 0; i < class_doc->signals.size(); i++) {
- if (class_doc->signals[i].name == signal_name.operator String()) {
- descr = DTR(class_doc->signals[i].description);
- break;
- }
- }
- }
- descr_cache[doc_class_name][signal_name] = descr;
- }
-
// "::" separators used in make_custom_tooltip for formatting.
signal_item->set_tooltip_text(0, String(signal_name) + "::" + signame.trim_prefix(mi.name) + "::" + descr);
}