mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Explicitly wait for SigScanner before plugin.Load (#897)
This commit is contained in:
parent
cf13e4f69d
commit
86b5eec493
1 changed files with 13 additions and 8 deletions
|
|
@ -17,7 +17,6 @@ using Dalamud.Game;
|
|||
using Dalamud.Game.Gui;
|
||||
using Dalamud.Game.Gui.Dtr;
|
||||
using Dalamud.Game.Text;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Internal;
|
||||
using Dalamud.Logging.Internal;
|
||||
using Dalamud.Plugin.Internal.Exceptions;
|
||||
|
|
@ -315,13 +314,13 @@ internal partial class PluginManager : IDisposable
|
|||
// Dev plugins should load first.
|
||||
pluginDefs.InsertRange(0, devPluginDefs);
|
||||
|
||||
void LoadPluginOnBoot(string logPrefix, PluginDef pluginDef)
|
||||
Task LoadPluginOnBoot(string logPrefix, PluginDef pluginDef)
|
||||
{
|
||||
using (Timings.Start($"{pluginDef.DllFile.Name}: {logPrefix}Boot"))
|
||||
{
|
||||
try
|
||||
{
|
||||
this.LoadPlugin(
|
||||
return this.LoadPluginAsync(
|
||||
pluginDef.DllFile,
|
||||
pluginDef.Manifest,
|
||||
PluginLoadReason.Boot,
|
||||
|
|
@ -337,19 +336,21 @@ internal partial class PluginManager : IDisposable
|
|||
Log.Error(ex, "{0}: During boot plugin load, an unexpected error occurred", logPrefix);
|
||||
}
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
void LoadPluginsSync(string logPrefix, IEnumerable<PluginDef> pluginDefsList)
|
||||
{
|
||||
foreach (var pluginDef in pluginDefsList)
|
||||
LoadPluginOnBoot(logPrefix, pluginDef);
|
||||
LoadPluginOnBoot(logPrefix, pluginDef).Wait();
|
||||
}
|
||||
|
||||
Task LoadPluginsAsync(string logPrefix, IEnumerable<PluginDef> pluginDefsList)
|
||||
{
|
||||
return Task.WhenAll(
|
||||
pluginDefsList
|
||||
.Select(pluginDef => Task.Run(() => LoadPluginOnBoot(logPrefix, pluginDef)))
|
||||
.Select(pluginDef => LoadPluginOnBoot(logPrefix, pluginDef))
|
||||
.ToArray());
|
||||
}
|
||||
|
||||
|
|
@ -538,7 +539,8 @@ internal partial class PluginManager : IDisposable
|
|||
try
|
||||
{
|
||||
// Add them to the list and let the user decide, nothing is auto-loaded.
|
||||
this.LoadPlugin(dllFile, manifest, PluginLoadReason.Installer, isDev: true, doNotLoad: true);
|
||||
this.LoadPluginAsync(dllFile, manifest, PluginLoadReason.Installer, isDev: true, doNotLoad: true)
|
||||
.Wait();
|
||||
listChanged = true;
|
||||
}
|
||||
catch (InvalidPluginException)
|
||||
|
|
@ -656,7 +658,7 @@ internal partial class PluginManager : IDisposable
|
|||
|
||||
Log.Information($"Installed plugin {manifest.Name} (testing={useTesting})");
|
||||
|
||||
var plugin = this.LoadPlugin(dllFile, manifest, reason);
|
||||
var plugin = await this.LoadPluginAsync(dllFile, manifest, reason);
|
||||
|
||||
this.NotifyInstalledPluginsChanged();
|
||||
return plugin;
|
||||
|
|
@ -672,7 +674,7 @@ internal partial class PluginManager : IDisposable
|
|||
/// <param name="isBoot">If this plugin is being loaded at boot.</param>
|
||||
/// <param name="doNotLoad">Don't load the plugin, just don't do it.</param>
|
||||
/// <returns>The loaded plugin.</returns>
|
||||
public LocalPlugin LoadPlugin(FileInfo dllFile, LocalPluginManifest? manifest, PluginLoadReason reason, bool isDev = false, bool isBoot = false, bool doNotLoad = false)
|
||||
public async Task<LocalPlugin> LoadPluginAsync(FileInfo dllFile, LocalPluginManifest? manifest, PluginLoadReason reason, bool isDev = false, bool isBoot = false, bool doNotLoad = false)
|
||||
{
|
||||
var name = manifest?.Name ?? dllFile.Name;
|
||||
var loadPlugin = !doNotLoad;
|
||||
|
|
@ -704,6 +706,9 @@ internal partial class PluginManager : IDisposable
|
|||
if (plugin.IsDisabled)
|
||||
plugin.Enable();
|
||||
|
||||
// Await for things that plugin just require
|
||||
_ = await Service<SigScanner>.GetAsync();
|
||||
|
||||
plugin.Load(reason);
|
||||
}
|
||||
catch (InvalidPluginException)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue