Retry loading addons after filesystem scan
This commit is contained in:
parent
5674fa04ae
commit
f2367e0782
4 changed files with 26 additions and 0 deletions
|
@ -96,6 +96,11 @@
|
|||
Emitted if at least one resource is reloaded when the filesystem is scanned.
|
||||
</description>
|
||||
</signal>
|
||||
<signal name="script_classes_updated">
|
||||
<description>
|
||||
Emitted when the list of global script classes gets updated.
|
||||
</description>
|
||||
</signal>
|
||||
<signal name="sources_changed">
|
||||
<param index="0" name="exist" type="bool" />
|
||||
<description>
|
||||
|
|
|
@ -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")));
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue