summaryrefslogtreecommitdiffstats
path: root/editor/editor_help.cpp
diff options
context:
space:
mode:
authorPedro J. Estébanez <pedrojrulez@gmail.com>2023-04-25 11:40:56 +0200
committerPedro J. Estébanez <pedrojrulez@gmail.com>2023-04-25 11:40:56 +0200
commite1ce0340b78875a864d449a5e3e38e4535e9a800 (patch)
tree078698c4f796388656ff48804e5d86ad864cfa14 /editor/editor_help.cpp
parent14c582bca81046fdde35e16088ddfd5df0136d56 (diff)
downloadredot-engine-e1ce0340b78875a864d449a5e3e38e4535e9a800.tar.gz
Improve reliability of editor docs cache
Diffstat (limited to 'editor/editor_help.cpp')
-rw-r--r--editor/editor_help.cpp30
1 files changed, 6 insertions, 24 deletions
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index c2801e1188..b9634a7e03 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -34,7 +34,6 @@
#include "core/input/input.h"
#include "core/os/keyboard.h"
#include "core/version.h"
-#include "core/version_generated.gen.h"
#include "doc_data_compressed.gen.h"
#include "editor/editor_node.h"
#include "editor/editor_paths.h"
@@ -2202,16 +2201,18 @@ String EditorHelp::get_cache_full_path() {
}
static bool first_attempt = true;
-static List<StringName> classes_whitelist;
+
+static String _compute_doc_version_hash() {
+ return uitos(ClassDB::get_api_hash(ClassDB::API_CORE)) + "-" + uitos(ClassDB::get_api_hash(ClassDB::API_EDITOR));
+}
void EditorHelp::_load_doc_thread(void *p_udata) {
DEV_ASSERT(first_attempt);
Ref<DocCache> cache_res = ResourceLoader::load(get_cache_full_path());
- if (cache_res.is_valid() && cache_res->get_version_hash() == String(VERSION_HASH)) {
+ if (cache_res.is_valid() && cache_res->get_version_hash() == _compute_doc_version_hash()) {
for (int i = 0; i < cache_res->get_classes().size(); i++) {
doc->add_doc(DocData::ClassDoc::from_dict(cache_res->get_classes()[i]));
}
- classes_whitelist.clear();
} else {
// We have to go back to the main thread to start from scratch.
first_attempt = false;
@@ -2226,7 +2227,7 @@ void EditorHelp::_gen_doc_thread(void *p_udata) {
Ref<DocCache> cache_res;
cache_res.instantiate();
- cache_res->set_version_hash(VERSION_HASH);
+ cache_res->set_version_hash(_compute_doc_version_hash());
Array classes;
for (const KeyValue<String, DocData::ClassDoc> &E : doc->class_list) {
classes.push_back(DocData::ClassDoc::to_dict(E.value));
@@ -2249,9 +2250,6 @@ void EditorHelp::generate_doc(bool p_use_cache) {
DEV_ASSERT(first_attempt == (doc == nullptr));
if (!doc) {
- // Classes registered after this point should not have documentation generated.
- ClassDB::get_class_list(&classes_whitelist);
-
GDREGISTER_CLASS(DocCache);
doc = memnew(DocTools);
}
@@ -2265,22 +2263,6 @@ void EditorHelp::generate_doc(bool p_use_cache) {
} else {
print_verbose("Regenerating editor help cache");
- if (!first_attempt) {
- // Some classes that should not be exposed may have been registered by now. Unexpose them.
- // Arduous, but happens only when regenerating.
- List<StringName> current_classes;
- ClassDB::get_class_list(&current_classes);
- List<StringName>::Element *W = classes_whitelist.front();
- for (const StringName &name : current_classes) {
- if (W && W->get() == name) {
- W = W->next();
- } else {
- ClassDB::classes[name].exposed = false;
- }
- }
- }
- classes_whitelist.clear();
-
// Not doable on threads unfortunately, since it instantiates all sorts of classes to get default values.
doc->generate(true);