1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 15:43:22 +08:00

Detach at point of usage, rather than point of retrieval

This commit is contained in:
Dean Herbert 2021-01-11 19:47:51 +09:00
parent 536e7229d0
commit 8f9b19a76e
2 changed files with 6 additions and 4 deletions

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Input.Bindings; using osu.Framework.Input.Bindings;
using osu.Game.Database;
using osu.Game.Rulesets; using osu.Game.Rulesets;
namespace osu.Game.Input.Bindings namespace osu.Game.Input.Bindings
@ -63,7 +64,7 @@ namespace osu.Game.Input.Bindings
// fallback to defaults instead. // fallback to defaults instead.
KeyBindings = DefaultKeyBindings; KeyBindings = DefaultKeyBindings;
else else
KeyBindings = store.Query(ruleset?.ID, variant); KeyBindings = store.Query(ruleset?.ID, variant).Detach();
} }
} }
} }

View File

@ -6,12 +6,13 @@ using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Database;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Input; using osu.Game.Input;
using osu.Game.Overlays.Settings; using osu.Game.Overlays.Settings;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osuTK; using osuTK;
using osu.Game.Graphics;
namespace osu.Game.Overlays.KeyBinding namespace osu.Game.Overlays.KeyBinding
{ {
@ -34,14 +35,14 @@ namespace osu.Game.Overlays.KeyBinding
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(RealmKeyBindingStore store) private void load(RealmKeyBindingStore store)
{ {
var bindings = store.Query(Ruleset?.ID, variant); var bindings = store.Query(Ruleset?.ID, variant).Detach();
foreach (var defaultGroup in Defaults.GroupBy(d => d.Action)) foreach (var defaultGroup in Defaults.GroupBy(d => d.Action))
{ {
int intKey = (int)defaultGroup.Key; int intKey = (int)defaultGroup.Key;
// one row per valid action. // one row per valid action.
Add(new KeyBindingRow(defaultGroup.Key, bindings.Where(b => ((int)b.Action).Equals(intKey))) Add(new KeyBindingRow(defaultGroup.Key, bindings.Where(b => b.Action.Equals(intKey)))
{ {
AllowMainMouseButtons = Ruleset != null, AllowMainMouseButtons = Ruleset != null,
Defaults = defaultGroup.Select(d => d.KeyCombination) Defaults = defaultGroup.Select(d => d.KeyCombination)