From 8fb9aec730e71a8931ae8996bf478bd9ac512a23 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 15 Oct 2021 16:39:53 +0900 Subject: [PATCH] Fix threaded realm usage not disposing context fast enough --- .../Configuration/RulesetConfigManager.cs | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/osu.Game/Rulesets/Configuration/RulesetConfigManager.cs b/osu.Game/Rulesets/Configuration/RulesetConfigManager.cs index 901efc3155..eec71a3623 100644 --- a/osu.Game/Rulesets/Configuration/RulesetConfigManager.cs +++ b/osu.Game/Rulesets/Configuration/RulesetConfigManager.cs @@ -59,15 +59,21 @@ namespace osu.Game.Rulesets.Configuration pendingWrites.Clear(); } - realmFactory?.CreateContext().Write(realm => - { - foreach (var c in changed) - { - var setting = realm.All().First(s => s.RulesetID == rulesetId && s.Variant == variant && s.Key == c.ToString()); + if (realmFactory == null) + return true; - setting.Value = ConfigStore[c].ToString(); - } - }); + using (var context = realmFactory.CreateContext()) + { + context.Write(realm => + { + foreach (var c in changed) + { + var setting = realm.All().First(s => s.RulesetID == rulesetId && s.Variant == variant && s.Key == c.ToString()); + + setting.Value = ConfigStore[c].ToString(); + } + }); + } return true; }