diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-01-16 09:47:17 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-01-16 09:47:17 +0100 |
commit | 0f0b853c988f2c3ff322d8eaf97dd4f8d5de46c8 (patch) | |
tree | 0257b7edd2ee8959e4db4e244751d62aceae014c /editor/editor_node.cpp | |
parent | b45bd946c669e2fff8ac7b6f2bb00273a2844f70 (diff) | |
parent | f2367e078200dadddc00a2738ba7efbe1b1403bf (diff) |
Merge pull request #70668 from KoBeWi/never_give_up
Retry loading addons after filesystem scan
Diffstat (limited to 'editor/editor_node.cpp')
-rw-r--r-- | editor/editor_node.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index c0feb7f966..62223b2445 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -634,6 +634,10 @@ void EditorNode::_notification(int p_what) { set_addon_plugin_enabled(addons[i], true); } _initializing_plugins = false; + + if (!pending_addons.is_empty()) { + EditorFileSystem::get_singleton()->connect("script_classes_updated", callable_mp(this, &EditorNode::_enable_pending_addons)); + } } RenderingServer::get_singleton()->viewport_set_disable_2d(get_scene_root()->get_viewport_rid(), true); @@ -3473,6 +3477,12 @@ void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled, // Errors in the script cause the base_type to be an empty StringName. if (scr->get_instance_base_type() == StringName()) { + if (_initializing_plugins) { + // However, if it happens during initialization, waiting for file scan might help. + pending_addons.push_back(p_addon); + return; + } + show_warning(vformat(TTR("Unable to load addon script from path: '%s'. This might be due to a code error in that script.\nDisabling the addon at '%s' to prevent further errors."), script_path, addon_path)); _remove_plugin_from_enabled(addon_path); return; @@ -4378,6 +4388,13 @@ void EditorNode::_build_icon_type_cache() { } } +void EditorNode::_enable_pending_addons() { + for (uint32_t i = 0; i < pending_addons.size(); i++) { + set_addon_plugin_enabled(pending_addons[i], true); + } + pending_addons.clear(); +} + void EditorNode::_file_dialog_register(FileDialog *p_dialog) { singleton->file_dialogs.insert(p_dialog); } |