Merge remote-tracking branch 'origin/master' into net8-rollup

This commit is contained in:
github-actions[bot] 2024-03-16 16:02:57 +00:00
commit 4abb3535fa
98 changed files with 3002 additions and 778 deletions

View file

@ -52,7 +52,7 @@ public sealed class DalamudPluginInterface : IDisposable
var dataManager = Service<DataManager>.Get();
var localization = Service<Localization>.Get();
this.UiBuilder = new UiBuilder(plugin.Name);
this.UiBuilder = new UiBuilder(plugin.Name, plugin);
this.configs = Service<PluginManager>.Get().PluginConfigs;
this.Reason = reason;
@ -452,26 +452,28 @@ public sealed class DalamudPluginInterface : IDisposable
#endregion
/// <summary>
/// Unregister your plugin and dispose all references.
/// </summary>
/// <inheritdoc cref="Dispose"/>
void IDisposable.Dispose()
{
this.UiBuilder.ExplicitDispose();
Service<ChatGui>.Get().RemoveChatLinkHandler(this.plugin.InternalName);
Service<Localization>.Get().LocalizationChanged -= this.OnLocalizationChanged;
Service<DalamudConfiguration>.Get().DalamudConfigurationSaved -= this.OnDalamudConfigurationSaved;
}
/// <summary>
/// Obsolete implicit dispose implementation. Should not be used.
/// </summary>
[Obsolete("Do not dispose \"DalamudPluginInterface\".", true)]
/// <summary>This function will do nothing. Dalamud will dispose this object on plugin unload.</summary>
[Obsolete("This function will do nothing. Dalamud will dispose this object on plugin unload.", true)]
public void Dispose()
{
// ignored
}
/// <summary>Unregister the plugin and dispose all references.</summary>
/// <remarks>Dalamud internal use only.</remarks>
internal void DisposeInternal()
{
Service<ChatGui>.Get().RemoveChatLinkHandler(this.plugin.InternalName);
Service<Localization>.Get().LocalizationChanged -= this.OnLocalizationChanged;
Service<DalamudConfiguration>.Get().DalamudConfigurationSaved -= this.OnDalamudConfigurationSaved;
this.UiBuilder.DisposeInternal();
}
/// <summary>
/// Dispatch the active plugins changed event.
/// </summary>

View file

@ -55,7 +55,7 @@ namespace Dalamud.Plugin.Internal;
[InherentDependency<DataShare>]
#pragma warning restore SA1015
internal partial class PluginManager : IDisposable, IServiceType
internal partial class PluginManager : IInternalDisposableService
{
/// <summary>
/// Default time to wait between plugin unload and plugin assembly unload.
@ -371,7 +371,7 @@ internal partial class PluginManager : IDisposable, IServiceType
}
/// <inheritdoc/>
public void Dispose()
void IInternalDisposableService.DisposeService()
{
var disposablePlugins =
this.installedPluginsList.Where(plugin => plugin.State is PluginState.Loaded or PluginState.LoadError).ToArray();
@ -411,7 +411,16 @@ internal partial class PluginManager : IDisposable, IServiceType
// Now that we've waited enough, dispose the whole plugin.
// Since plugins should have been unloaded above, this should be done quickly.
foreach (var plugin in disposablePlugins)
plugin.ExplicitDisposeIgnoreExceptions($"Error disposing {plugin.Name}", Log);
{
try
{
plugin.Dispose();
}
catch (Exception e)
{
Log.Error(e, $"Error disposing {plugin.Name}");
}
}
}
// NET8 CHORE

View file

@ -16,7 +16,7 @@ namespace Dalamud.Plugin.Internal.Profiles;
/// Service responsible for profile-related chat commands.
/// </summary>
[ServiceManager.EarlyLoadedService]
internal class ProfileCommandHandler : IServiceType, IDisposable
internal class ProfileCommandHandler : IInternalDisposableService
{
private readonly CommandManager cmd;
private readonly ProfileManager profileManager;
@ -69,7 +69,7 @@ internal class ProfileCommandHandler : IServiceType, IDisposable
}
/// <inheritdoc/>
public void Dispose()
void IInternalDisposableService.DisposeService()
{
this.cmd.RemoveHandler("/xlenablecollection");
this.cmd.RemoveHandler("/xldisablecollection");

View file

@ -5,6 +5,7 @@ using System.Threading;
using System.Threading.Tasks;
using Dalamud.Configuration.Internal;
using Dalamud.Interface.ImGuiNotification.Internal;
using Dalamud.Interface.Internal.Notifications;
using Dalamud.Logging.Internal;
using Dalamud.Plugin.Internal.Types.Manifest;

View file

@ -240,7 +240,7 @@ internal class LocalPlugin : IDisposable
this.instance = null;
}
this.DalamudInterface?.ExplicitDispose();
this.DalamudInterface?.DisposeInternal();
this.DalamudInterface = null;
this.ServiceScope?.Dispose();
@ -427,7 +427,7 @@ internal class LocalPlugin : IDisposable
if (this.instance == null)
{
this.State = PluginState.LoadError;
this.DalamudInterface.ExplicitDispose();
this.DalamudInterface.DisposeInternal();
Log.Error(
$"Error while loading {this.Name}, failed to bind and call the plugin constructor");
return;
@ -500,7 +500,7 @@ internal class LocalPlugin : IDisposable
this.instance = null;
this.DalamudInterface?.ExplicitDispose();
this.DalamudInterface?.DisposeInternal();
this.DalamudInterface = null;
this.ServiceScope?.Dispose();

View file

@ -0,0 +1,12 @@
using Dalamud.Interface.ImGuiNotification;
namespace Dalamud.Plugin.Services;
/// <summary>Manager for notifications provided by Dalamud using ImGui.</summary>
public interface INotificationManager
{
/// <summary>Adds a notification.</summary>
/// <param name="notification">The new notification.</param>
/// <returns>The added notification.</returns>
IActiveNotification AddNotification(Notification notification);
}