mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-13 12:14:16 +01:00
Merge pull request #1409 from MidoriKami/DelegateNullification
This commit is contained in:
commit
201a927952
9 changed files with 42 additions and 16 deletions
|
|
@ -189,6 +189,8 @@ internal class ConditionPluginScoped : IDisposable, IServiceType, ICondition
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
this.conditionService.ConditionChange -= this.ConditionChangedForward;
|
this.conditionService.ConditionChange -= this.ConditionChangedForward;
|
||||||
|
|
||||||
|
this.ConditionChange = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
|
|
||||||
|
|
@ -210,6 +210,11 @@ internal class DutyStatePluginScoped : IDisposable, IServiceType, IDutyState
|
||||||
this.dutyStateService.DutyWiped -= this.DutyWipedForward;
|
this.dutyStateService.DutyWiped -= this.DutyWipedForward;
|
||||||
this.dutyStateService.DutyRecommenced -= this.DutyRecommencedForward;
|
this.dutyStateService.DutyRecommenced -= this.DutyRecommencedForward;
|
||||||
this.dutyStateService.DutyCompleted -= this.DutyCompletedForward;
|
this.dutyStateService.DutyCompleted -= this.DutyCompletedForward;
|
||||||
|
|
||||||
|
this.DutyStarted = null;
|
||||||
|
this.DutyWiped = null;
|
||||||
|
this.DutyRecommenced = null;
|
||||||
|
this.DutyCompleted = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DutyStartedForward(object sender, ushort territoryId) => this.DutyStarted?.Invoke(sender, territoryId);
|
private void DutyStartedForward(object sender, ushort territoryId) => this.DutyStarted?.Invoke(sender, territoryId);
|
||||||
|
|
|
||||||
|
|
@ -460,6 +460,11 @@ internal class ChatGuiPluginScoped : IDisposable, IServiceType, IChatGui
|
||||||
this.chatGuiService.CheckMessageHandled -= this.OnCheckMessageForward;
|
this.chatGuiService.CheckMessageHandled -= this.OnCheckMessageForward;
|
||||||
this.chatGuiService.ChatMessageHandled -= this.OnMessageHandledForward;
|
this.chatGuiService.ChatMessageHandled -= this.OnMessageHandledForward;
|
||||||
this.chatGuiService.ChatMessageUnhandled -= this.OnMessageUnhandledForward;
|
this.chatGuiService.ChatMessageUnhandled -= this.OnMessageUnhandledForward;
|
||||||
|
|
||||||
|
this.ChatMessage = null;
|
||||||
|
this.CheckMessageHandled = null;
|
||||||
|
this.ChatMessageHandled = null;
|
||||||
|
this.ChatMessageUnhandled = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
|
|
||||||
|
|
@ -307,6 +307,8 @@ internal class FlyTextGuiPluginScoped : IDisposable, IServiceType, IFlyTextGui
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
this.flyTextGuiService.FlyTextCreated -= this.FlyTextCreatedForward;
|
this.flyTextGuiService.FlyTextCreated -= this.FlyTextCreatedForward;
|
||||||
|
|
||||||
|
this.FlyTextCreated = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
|
|
||||||
|
|
@ -566,6 +566,10 @@ internal class GameGuiPluginScoped : IDisposable, IServiceType, IGameGui
|
||||||
this.gameGuiService.UiHideToggled -= this.UiHideToggledForward;
|
this.gameGuiService.UiHideToggled -= this.UiHideToggledForward;
|
||||||
this.gameGuiService.HoveredItemChanged -= this.HoveredItemForward;
|
this.gameGuiService.HoveredItemChanged -= this.HoveredItemForward;
|
||||||
this.gameGuiService.HoveredActionChanged -= this.HoveredActionForward;
|
this.gameGuiService.HoveredActionChanged -= this.HoveredActionForward;
|
||||||
|
|
||||||
|
this.UiHideToggled = null;
|
||||||
|
this.HoveredItemChanged = null;
|
||||||
|
this.HoveredActionChanged = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
|
|
||||||
|
|
@ -156,6 +156,8 @@ internal class PartyFinderGuiPluginScoped : IDisposable, IServiceType, IPartyFin
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
this.partyFinderGuiService.ReceiveListing -= this.ReceiveListingForward;
|
this.partyFinderGuiService.ReceiveListing -= this.ReceiveListingForward;
|
||||||
|
|
||||||
|
this.ReceiveListing = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReceiveListingForward(PartyFinderListing listing, PartyFinderListingEventArgs args) => this.ReceiveListing?.Invoke(listing, args);
|
private void ReceiveListingForward(PartyFinderListing listing, PartyFinderListingEventArgs args) => this.ReceiveListing?.Invoke(listing, args);
|
||||||
|
|
|
||||||
|
|
@ -417,6 +417,10 @@ internal class ToastGuiPluginScoped : IDisposable, IServiceType, IToastGui
|
||||||
this.toastGuiService.Toast -= this.ToastForward;
|
this.toastGuiService.Toast -= this.ToastForward;
|
||||||
this.toastGuiService.QuestToast -= this.QuestToastForward;
|
this.toastGuiService.QuestToast -= this.QuestToastForward;
|
||||||
this.toastGuiService.ErrorToast -= this.ErrorToastForward;
|
this.toastGuiService.ErrorToast -= this.ErrorToastForward;
|
||||||
|
|
||||||
|
this.Toast = null;
|
||||||
|
this.QuestToast = null;
|
||||||
|
this.ErrorToast = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
|
|
||||||
|
|
@ -169,6 +169,8 @@ internal class GameNetworkPluginScoped : IDisposable, IServiceType, IGameNetwork
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
this.gameNetworkService.NetworkMessage -= this.NetworkMessageForward;
|
this.gameNetworkService.NetworkMessage -= this.NetworkMessageForward;
|
||||||
|
|
||||||
|
this.NetworkMessage = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NetworkMessageForward(nint dataPtr, ushort opCode, uint sourceActorId, uint targetActorId, NetworkMessageDirection direction)
|
private void NetworkMessageForward(nint dataPtr, ushort opCode, uint sourceActorId, uint targetActorId, NetworkMessageDirection direction)
|
||||||
|
|
|
||||||
|
|
@ -609,7 +609,23 @@ public static class Util
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Overwrite text in a file by first writing it to a temporary file, and then
|
||||||
|
/// moving that file to the path specified.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">The path of the file to write to.</param>
|
||||||
|
/// <param name="text">The text to write.</param>
|
||||||
|
public static void WriteAllTextSafe(string path, string text)
|
||||||
|
{
|
||||||
|
var tmpPath = path + ".tmp";
|
||||||
|
if (File.Exists(tmpPath))
|
||||||
|
File.Delete(tmpPath);
|
||||||
|
|
||||||
|
File.WriteAllText(tmpPath, text);
|
||||||
|
File.Move(tmpPath, path, true);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Dispose this object.
|
/// Dispose this object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -645,22 +661,6 @@ public static class Util
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Overwrite text in a file by first writing it to a temporary file, and then
|
|
||||||
/// moving that file to the path specified.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="path">The path of the file to write to.</param>
|
|
||||||
/// <param name="text">The text to write.</param>
|
|
||||||
internal static void WriteAllTextSafe(string path, string text)
|
|
||||||
{
|
|
||||||
var tmpPath = path + ".tmp";
|
|
||||||
if (File.Exists(tmpPath))
|
|
||||||
File.Delete(tmpPath);
|
|
||||||
|
|
||||||
File.WriteAllText(tmpPath, text);
|
|
||||||
File.Move(tmpPath, path, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a random, inoffensive, human-friendly string.
|
/// Gets a random, inoffensive, human-friendly string.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue