mirror of
https://github.com/ppy/osu.git
synced 2025-03-15 17:47:18 +08:00
Fix thread safety of KeyBindingStore.GetReadableKeyCombinationsFor
This commit is contained in:
parent
c369beeaaa
commit
d06e52505a
@ -26,16 +26,23 @@ namespace osu.Game.Input
|
||||
/// </summary>
|
||||
/// <param name="globalAction">The action to lookup.</param>
|
||||
/// <returns>A set of display strings for all the user's key configuration for the action.</returns>
|
||||
public IEnumerable<string> GetReadableKeyCombinationsFor(GlobalAction globalAction)
|
||||
public IReadOnlyList<string> GetReadableKeyCombinationsFor(GlobalAction globalAction)
|
||||
{
|
||||
foreach (var action in realmFactory.Context.All<RealmKeyBinding>().Where(b => (GlobalAction)b.ActionInt == globalAction))
|
||||
{
|
||||
string str = action.KeyCombination.ReadableString();
|
||||
List<string> combinations = new List<string>();
|
||||
|
||||
// even if found, the readable string may be empty for an unbound action.
|
||||
if (str.Length > 0)
|
||||
yield return str;
|
||||
using (var context = realmFactory.GetForRead())
|
||||
{
|
||||
foreach (var action in context.Realm.All<RealmKeyBinding>().Where(b => (GlobalAction)b.ActionInt == globalAction))
|
||||
{
|
||||
string str = action.KeyCombination.ReadableString();
|
||||
|
||||
// even if found, the readable string may be empty for an unbound action.
|
||||
if (str.Length > 0)
|
||||
combinations.Add(str);
|
||||
}
|
||||
}
|
||||
|
||||
return combinations;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -608,9 +608,9 @@ namespace osu.Game
|
||||
|
||||
LocalConfig.LookupKeyBindings = l =>
|
||||
{
|
||||
var combinations = KeyBindingStore.GetReadableKeyCombinationsFor(l).ToArray();
|
||||
var combinations = KeyBindingStore.GetReadableKeyCombinationsFor(l);
|
||||
|
||||
if (combinations.Length == 0)
|
||||
if (combinations.Count == 0)
|
||||
return "none";
|
||||
|
||||
return string.Join(" or ", combinations);
|
||||
|
Loading…
x
Reference in New Issue
Block a user