Skip to content

Commit

Permalink
fix: LoadErrorManagerの初期化に失敗することがある不具合を修正
Browse files Browse the repository at this point in the history
  • Loading branch information
automatic9045 committed Apr 29, 2022
1 parent 92a52a5 commit 43b19e6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
20 changes: 19 additions & 1 deletion AtsEx.PluginHost/Helpers/LoadErrorManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,25 @@ namespace Automatic9045.AtsEx.PluginHost.Helpers
{
public static partial class LoadErrorManager
{
public static LoadErrorList Errors { get; } = new LoadErrorList();
static LoadErrorManager()
{
if (InstanceStore.IsInitialized)
{
Initialize();
}
else
{
InstanceStore.Initialized += e => Initialize();
}
}

private static void Initialize()
{
Errors = new LoadErrorList();
}


public static LoadErrorList Errors { get; private set; }


public static void Throw(string text, string senderFileName, int lineIndex, int charIndex)
Expand Down
4 changes: 4 additions & 0 deletions AtsEx.PluginHost/InstanceStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace Automatic9045.AtsEx.PluginHost
{
internal delegate void InitializedEventHandler(EventArgs e);
internal delegate void ClosingEventHandler(EventArgs e);

public static class InstanceStore
Expand All @@ -20,6 +21,7 @@ public static class InstanceStore
private static IBveHacker bveHacker;
internal static IBveHacker BveHacker => IsInitialized ? bveHacker : throw new InvalidOperationException($"{nameof(InstanceStore)} は初期化されていません。");

internal static event InitializedEventHandler Initialized;
internal static event ClosingEventHandler Closing;

public static void Initialize(IApp app, IBveHacker bveHacker)
Expand All @@ -29,6 +31,8 @@ public static void Initialize(IApp app, IBveHacker bveHacker)

InstanceStore.app = app;
InstanceStore.bveHacker = bveHacker;

Initialized?.Invoke(EventArgs.Empty);
}

public static void Dispose()
Expand Down

0 comments on commit 43b19e6

Please sign in to comment.