1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-22 22:37:19 +08:00
Dean Herbert 531794b26b Fix ModelManager not correctly re-retrieving realm objects before performing operations
Falls into the age-old trap of attempting to retrieve an item from realm
without first ensuring that realm is in an up-to-date state.

Consider this scenario:

- Editor is entered from main menu, causing it to create a new beatmap
  from its async `load()` method.
- Editor opens correctly, then main thread performs a file operations on
  the same beatmap.
- Main thread is potentially not refreshed yet, and will result in `null`
  instance when performing the re-fetch in `performFileOperation`.

I've fixed this by using the safe implementation inside `RealmLive<T>`.
Feels like we want this is one place which is always used as the correct
method.

On a quick search, there are 10-20 other usages of `Realm.Find<T>` which
could also have similar issues, but it'll be a bit of a pain to go
through and fix each of these. In 99.9% of cases, the accesses are on
instances which couldn't have just been created (or the usage of
recently-imported/created is blocked by realm subscription flows, ie.
baetmap import) so I'm not touching them for now.

Something to keep in mind when working with realm going forward though.
2023-08-16 14:23:32 +09:00
..
2023-07-06 13:37:43 +09:00
2023-06-24 01:00:03 +09:00
2023-06-24 01:00:03 +09:00
2023-08-15 00:58:13 +09:00
2023-07-16 10:21:32 +08:00
2023-07-08 15:03:33 +02:00
2023-07-04 14:50:34 +09:00
2023-07-20 17:51:33 +09:00
2023-08-15 14:33:21 +09:00
2023-06-24 01:00:03 +09:00
2023-06-29 17:15:48 +09:00