Skip to content

Commit

Permalink
fix: uncaught exceptions from language change callbacks stop subseque…
Browse files Browse the repository at this point in the history
…nt callbacks
  • Loading branch information
bdunderscore committed Dec 29, 2023
1 parent 02b58c1 commit 07fad0c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- API to record when one object is replaced by another

### Fixed
- Exceptions leaking out of language change callbacks break subsequent callbacks (#103)
- Deregistering a language change callback while callbacks are running could skip executing some callbacks (#103)

### Changed

Expand Down
10 changes: 9 additions & 1 deletion Editor/UI/Localization/LanguagePrefs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Runtime.CompilerServices;
using UnityEngine;

namespace nadena.dev.ndmf.localization
{
Expand Down Expand Up @@ -84,7 +85,14 @@ private static void TriggerLanguageChangeCallbacks()
{
foreach (Action op in new List<Action>(_onLanguageChangeCallbacks))
{
op();
try
{
op();
}
catch (Exception e)
{
Debug.LogException(e);
}
}
}
}
Expand Down

0 comments on commit 07fad0c

Please sign in to comment.