mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 19:42:55 +08:00
Add simple locking of resourceManagers dictionary for thread safety
This commit is contained in:
parent
31c8586dac
commit
e536f1ad6d
@ -31,18 +31,21 @@ namespace osu.Game.Localisation
|
|||||||
string ns = split[0];
|
string ns = split[0];
|
||||||
string key = split[1];
|
string key = split[1];
|
||||||
|
|
||||||
if (!resourceManagers.TryGetValue(ns, out var manager))
|
lock (resourceManagers)
|
||||||
resourceManagers[ns] = manager = new ResourceManager(ns, GetType().Assembly);
|
{
|
||||||
|
if (!resourceManagers.TryGetValue(ns, out var manager))
|
||||||
|
resourceManagers[ns] = manager = new ResourceManager(ns, GetType().Assembly);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return manager.GetString(key, EffectiveCulture);
|
return manager.GetString(key, EffectiveCulture);
|
||||||
}
|
}
|
||||||
catch (MissingManifestResourceException)
|
catch (MissingManifestResourceException)
|
||||||
{
|
{
|
||||||
// in the case the manifest is missing, it is likely that the user is adding code-first implementations of new localisation namespaces.
|
// in the case the manifest is missing, it is likely that the user is adding code-first implementations of new localisation namespaces.
|
||||||
// it's fine to ignore this as localisation will fallback to default values.
|
// it's fine to ignore this as localisation will fallback to default values.
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user