1
0
mirror of https://github.com/ppy/osu.git synced 2026-06-03 15:54:44 +08:00

Fix undisposed Realm subscription

This commit is contained in:
Dan Balasescu
2025-10-09 15:55:48 +09:00
Unverified
parent 79c367d208
commit 6af5158bb4
+12 -1
View File
@@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
@@ -77,6 +78,8 @@ namespace osu.Game.Overlays.Toolbar
protected readonly Container BackgroundContent;
private IDisposable? realmSubscription;
[Resolved]
private RealmAccess realm { get; set; } = null!;
@@ -184,7 +187,8 @@ namespace osu.Game.Overlays.Toolbar
{
if (Hotkey != null)
{
realm.SubscribeToPropertyChanged(r => r.All<RealmKeyBinding>().FirstOrDefault(rkb => rkb.RulesetName == null && rkb.ActionInt == (int)Hotkey.Value), kb => kb.KeyCombinationString, updateKeyBindingTooltip);
realmSubscription = realm.SubscribeToPropertyChanged(r => r.All<RealmKeyBinding>().FirstOrDefault(rkb => rkb.RulesetName == null && rkb.ActionInt == (int)Hotkey.Value),
kb => kb.KeyCombinationString, updateKeyBindingTooltip);
}
}
@@ -234,6 +238,13 @@ namespace osu.Game.Overlays.Toolbar
? $" ({keyBindingString})"
: string.Empty;
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
realmSubscription?.Dispose();
}
}
public partial class OpaqueBackground : Container