Skip to content

Commit bc46026

Browse files
authored
Merge pull request #2 from BroWar-Collective/hotfix/history-null-loop
Hotfix/history-stack-overflow
2 parents 4677f7d + ece2405 commit bc46026

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

Assets/Package/Runtime/Console/ConsoleManager.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,23 @@ public class ConsoleManager : MonoBehaviour, IConsoleManager
2727
private ConsoleHistory inputHistory;
2828

2929
private bool isInitialized;
30+
private bool isInitializing;
3031

3132
private void EnsureInitialized()
3233
{
33-
if (isInitialized)
34+
if (isInitialized || isInitializing)
3435
{
3536
return;
3637
}
3738

38-
isInitialized = true;
39-
InitializeCache();
39+
isInitializing = true;
40+
4041
ValidateSettings();
4142
InitializeHistory();
4243
InitializeCommands();
44+
45+
isInitialized = true;
46+
isInitializing = false;
4347
}
4448

4549
private void ValidateSettings()
@@ -63,6 +67,8 @@ private void InitializeHistory()
6367

6468
private void InitializeCommands()
6569
{
70+
InitializeCache();
71+
6672
var commandsRepository = settings.CommandsRepository;
6773
var commandsList = commandsRepository.commands;
6874
for (int i = 0; i < commandsList.Count; i++)
@@ -145,7 +151,7 @@ private bool TryMatchMethod(string commandNameLowerCased, string[] arguments, Ha
145151
return false;
146152
}
147153

148-
private void RegistorMethodFromCommand(ConsoleCommand command, MethodInfo method)
154+
private void RegisterMethodFromCommand(ConsoleCommand command, MethodInfo method)
149155
{
150156
var commandName = method.Name.ToLower();
151157
if (namesToMethods.TryGetValue(commandName, out var methodsGroup))
@@ -177,7 +183,7 @@ public void AppendCommand(ConsoleCommand command)
177183
var commandInfo = commandType.GetTypeInfo();
178184
foreach (var method in commandInfo.DeclaredMethods.Where(method => method.IsPublic))
179185
{
180-
RegistorMethodFromCommand(command, method);
186+
RegisterMethodFromCommand(command, method);
181187
}
182188
}
183189

0 commit comments

Comments
 (0)