diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_file_system.cpp | 2 | ||||
-rw-r--r-- | editor/editor_node.cpp | 17 | ||||
-rw-r--r-- | editor/editor_node.h | 2 |
3 files changed, 21 insertions, 0 deletions
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index b98480b594..50dce38f69 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -1527,6 +1527,7 @@ void EditorFileSystem::update_script_classes() { ScriptServer::save_global_classes(); EditorNode::get_editor_data().script_class_save_icon_paths(); + emit_signal("script_classes_updated"); // Rescan custom loaders and savers. // Doing the following here because the `filesystem_changed` signal fires multiple times and isn't always followed by script classes update. @@ -2417,6 +2418,7 @@ void EditorFileSystem::_bind_methods() { ClassDB::bind_method(D_METHOD("reimport_files", "files"), &EditorFileSystem::reimport_files); ADD_SIGNAL(MethodInfo("filesystem_changed")); + ADD_SIGNAL(MethodInfo("script_classes_updated")); ADD_SIGNAL(MethodInfo("sources_changed", PropertyInfo(Variant::BOOL, "exist"))); ADD_SIGNAL(MethodInfo("resources_reimported", PropertyInfo(Variant::PACKED_STRING_ARRAY, "resources"))); ADD_SIGNAL(MethodInfo("resources_reload", PropertyInfo(Variant::PACKED_STRING_ARRAY, "resources"))); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 01e605880c..923ff01dec 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -630,6 +630,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); @@ -3487,6 +3491,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; @@ -4394,6 +4404,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); } diff --git a/editor/editor_node.h b/editor/editor_node.h index 950970379d..a4dd7a44b5 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -292,6 +292,7 @@ private: Vector<EditorPlugin *> editor_plugins; bool _initializing_plugins = false; HashMap<String, EditorPlugin *> addon_name_to_plugin; + LocalVector<String> pending_addons; PanelContainer *scene_root_parent = nullptr; Control *theme_base = nullptr; @@ -535,6 +536,7 @@ private: static void _resource_loaded(Ref<Resource> p_resource, const String &p_path); void _build_icon_type_cache(); + void _enable_pending_addons(); void _dialog_action(String p_file); |