Only write when writes occur

Also add finaliser logic for safety. Also better threading. Also more cleanup.
This commit is contained in:
Dean Herbert
2018-02-12 19:57:21 +09:00
parent edc3638175
commit 8b37fde15b
8 changed files with 86 additions and 50 deletions

View File

@ -36,8 +36,6 @@ namespace osu.Game.Input
{
using (var usage = ContextFactory.GetForWrite())
{
var context = usage.Context;
// compare counts in database vs defaults
foreach (var group in defaults.GroupBy(k => k.Action))
{
@ -49,7 +47,7 @@ namespace osu.Game.Input
foreach (var insertable in group.Skip(count).Take(aimCount - count))
// insert any defaults which are missing.
context.DatabasedKeyBinding.Add(new DatabasedKeyBinding
usage.Context.DatabasedKeyBinding.Add(new DatabasedKeyBinding
{
KeyCombination = insertable.KeyCombination,
Action = insertable.Action,
@ -75,6 +73,10 @@ namespace osu.Game.Input
{
var dbKeyBinding = (DatabasedKeyBinding)keyBinding;
Refresh(ref dbKeyBinding);
if (dbKeyBinding.KeyCombination.Equals(keyBinding.KeyCombination))
return;
dbKeyBinding.KeyCombination = keyBinding.KeyCombination;
}