From a7c77ac1f711458a01bf3ea8a5fa97a3a87c2712 Mon Sep 17 00:00:00 2001 From: Michael Alexsander Date: Mon, 26 Jan 2026 20:02:43 -0300 Subject: [PATCH] Fix build profile generator creating bogus profiles --- core/io/resource_format_binary.cpp | 52 +++++++++++++----------- editor/settings/editor_build_profile.cpp | 15 ++++++- scene/gui/rich_text_label.cpp | 3 ++ 3 files changed, 46 insertions(+), 24 deletions(-) diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 7ce92989f7..8446e10413 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -1520,33 +1520,39 @@ void ResourceFormatLoaderBinary::get_classes_used(const String &p_path, HashSet< loader.res_path = loader.local_path; loader.get_classes_used(f, r_classes); - // Fetch the nodes inside scene files. - if (loader.type == "PackedScene") { - ERR_FAIL_COND(loader.load() != OK); + if (loader.type != "PackedScene") { + return; + } - Ref state = Ref(loader.get_resource())->get_state(); - for (int i = 0; i < state->get_node_count(); i++) { - const StringName node_name = state->get_node_type(i); - if (ClassDB::class_exists(node_name)) { - r_classes->insert(node_name); + // Fetch the nodes inside scene files. + + // Reopening is necessary, or errors will occur. + f->reopen(p_path, FileAccess::READ); + loader.open(f); + ERR_FAIL_COND(loader.load() != OK); + + Ref state = Ref(loader.get_resource())->get_state(); + for (int i = 0; i < state->get_node_count(); i++) { + const StringName node_name = state->get_node_type(i); + if (ClassDB::class_exists(node_name)) { + r_classes->insert(node_name); + } + + // Fetch the values of properties in the node. + for (int j = 0; j < state->get_node_property_count(i); j++) { + const Variant var = state->get_node_property_value(i, j); + if (var.get_type() != Variant::OBJECT) { + continue; } - // Fetch the values of properties in the node. - for (int j = 0; j < state->get_node_property_count(i); j++) { - const Variant var = state->get_node_property_value(i, j); - if (var.get_type() != Variant::OBJECT) { - continue; - } + const Object *obj = var.get_validated_object(); + if (obj == nullptr) { + continue; + } - const Object *obj = var.get_validated_object(); - if (obj == nullptr) { - continue; - } - - const StringName obj_name = obj->get_class_name(); - if (ClassDB::class_exists(obj_name)) { - r_classes->insert(obj_name); - } + const StringName obj_name = obj->get_class_name(); + if (ClassDB::class_exists(obj_name)) { + r_classes->insert(obj_name); } } } diff --git a/editor/settings/editor_build_profile.cpp b/editor/settings/editor_build_profile.cpp index 812544562b..1a940672d2 100644 --- a/editor/settings/editor_build_profile.cpp +++ b/editor/settings/editor_build_profile.cpp @@ -890,7 +890,20 @@ void EditorBuildProfileManager::_detect_from_project() { // Add classes that are either necessary for the engine to work properly, or there isn't a way to infer their use. - const LocalVector hardcoded_classes = { "InputEvent", "MainLoop", "StyleBox" }; + // HACK: Some classes are included due to creating clashes with unrelated when disabled. + // Until that is fixed, they need to always be enabled. + const LocalVector hardcoded_classes = { + "Font", + "InputEvent", + "MainLoop", + "Mutex", + "ShaderInclude", + "ShaderIncludeDB", + "StyleBox", + "Time", + "Window", + }; + for (const String &hc_class : hardcoded_classes) { used_classes.insert(hc_class); diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 0f0cb90fff..c4bd835f2c 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -7855,6 +7855,9 @@ void RichTextLabel::_bind_methods() { BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, RichTextLabel, table_border); ADD_CLASS_DEPENDENCY("PopupMenu"); +#ifdef MODULE_REGEX_ENABLED + ADD_CLASS_DEPENDENCY("RegEx"); +#endif } TextServer::VisibleCharactersBehavior RichTextLabel::get_visible_characters_behavior() const {