mirror of
https://github.com/ppy/osu.git
synced 2025-01-21 08:52:54 +08:00
Fix Realm-related iOS crashes by removing object references
This commit is contained in:
parent
84d7fed23d
commit
3ab04d98f6
@ -198,8 +198,10 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
if (beatmapSet.OnlineID > 0)
|
if (beatmapSet.OnlineID > 0)
|
||||||
{
|
{
|
||||||
|
int onlineId = beatmapSet.OnlineID;
|
||||||
|
|
||||||
// OnlineID should really be unique, but to avoid catastrophic failure let's iterate just to be sure.
|
// OnlineID should really be unique, but to avoid catastrophic failure let's iterate just to be sure.
|
||||||
foreach (var existingSetWithSameOnlineID in realm.All<BeatmapSetInfo>().Where(b => b.OnlineID == beatmapSet.OnlineID))
|
foreach (var existingSetWithSameOnlineID in realm.All<BeatmapSetInfo>().Where(b => b.OnlineID == onlineId))
|
||||||
{
|
{
|
||||||
existingSetWithSameOnlineID.DeletePending = true;
|
existingSetWithSameOnlineID.DeletePending = true;
|
||||||
existingSetWithSameOnlineID.OnlineID = -1;
|
existingSetWithSameOnlineID.OnlineID = -1;
|
||||||
|
@ -40,7 +40,9 @@ namespace osu.Game.Online
|
|||||||
// Used to interact with manager classes that don't support interface types. Will eventually be replaced.
|
// Used to interact with manager classes that don't support interface types. Will eventually be replaced.
|
||||||
var beatmapSetInfo = new BeatmapSetInfo { OnlineID = TrackedItem.OnlineID };
|
var beatmapSetInfo = new BeatmapSetInfo { OnlineID = TrackedItem.OnlineID };
|
||||||
|
|
||||||
realmSubscription = realm.RegisterForNotifications(r => r.All<BeatmapSetInfo>().Where(s => s.OnlineID == TrackedItem.OnlineID && !s.DeletePending), (items, _) =>
|
int onlineId = TrackedItem.OnlineID;
|
||||||
|
|
||||||
|
realmSubscription = realm.RegisterForNotifications(r => r.All<BeatmapSetInfo>().Where(s => s.OnlineID == onlineId && !s.DeletePending), (items, _) =>
|
||||||
{
|
{
|
||||||
if (items.Any())
|
if (items.Any())
|
||||||
Schedule(() => UpdateState(DownloadState.LocallyAvailable));
|
Schedule(() => UpdateState(DownloadState.LocallyAvailable));
|
||||||
|
@ -46,10 +46,14 @@ namespace osu.Game.Online
|
|||||||
Downloader.DownloadBegan += downloadBegan;
|
Downloader.DownloadBegan += downloadBegan;
|
||||||
Downloader.DownloadFailed += downloadFailed;
|
Downloader.DownloadFailed += downloadFailed;
|
||||||
|
|
||||||
|
long onlineId = TrackedItem.OnlineID;
|
||||||
|
long legacyOnlineId = TrackedItem.LegacyOnlineID;
|
||||||
|
string hash = TrackedItem.Hash;
|
||||||
|
|
||||||
realmSubscription = realm.RegisterForNotifications(r => r.All<ScoreInfo>().Where(s =>
|
realmSubscription = realm.RegisterForNotifications(r => r.All<ScoreInfo>().Where(s =>
|
||||||
((s.OnlineID > 0 && s.OnlineID == TrackedItem.OnlineID)
|
((s.OnlineID > 0 && s.OnlineID == onlineId)
|
||||||
|| (s.LegacyOnlineID > 0 && s.LegacyOnlineID == TrackedItem.LegacyOnlineID)
|
|| (s.LegacyOnlineID > 0 && s.LegacyOnlineID == legacyOnlineId)
|
||||||
|| (!string.IsNullOrEmpty(s.Hash) && s.Hash == TrackedItem.Hash))
|
|| (!string.IsNullOrEmpty(s.Hash) && s.Hash == hash))
|
||||||
&& !s.DeletePending), (items, _) =>
|
&& !s.DeletePending), (items, _) =>
|
||||||
{
|
{
|
||||||
if (items.Any())
|
if (items.Any())
|
||||||
|
@ -29,7 +29,9 @@ namespace osu.Game.Skinning
|
|||||||
invalidateCache();
|
invalidateCache();
|
||||||
Debug.Assert(fileToStoragePathMapping != null);
|
Debug.Assert(fileToStoragePathMapping != null);
|
||||||
|
|
||||||
realmSubscription = realm?.RegisterForNotifications(r => r.All<T>().Where(s => s.ID == source.ID), skinChanged);
|
Guid id = source.ID;
|
||||||
|
|
||||||
|
realmSubscription = realm?.RegisterForNotifications(r => r.All<T>().Where(s => s.ID == id), skinChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
|
@ -131,9 +131,11 @@ namespace osu.Game.Skinning
|
|||||||
{
|
{
|
||||||
Realm.Run(r =>
|
Realm.Run(r =>
|
||||||
{
|
{
|
||||||
|
Guid currentSkinId = CurrentSkinInfo.Value.ID;
|
||||||
|
|
||||||
// choose from only user skins, removing the current selection to ensure a new one is chosen.
|
// choose from only user skins, removing the current selection to ensure a new one is chosen.
|
||||||
var randomChoices = r.All<SkinInfo>()
|
var randomChoices = r.All<SkinInfo>()
|
||||||
.Where(s => !s.DeletePending && s.ID != CurrentSkinInfo.Value.ID)
|
.Where(s => !s.DeletePending && s.ID != currentSkinId)
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
if (randomChoices.Length == 0)
|
if (randomChoices.Length == 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user