Replay edits done during quests download #5473
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fixes #4258
This actually does not only concern quests, but also overlays, which is why the solution has been done in
MapDataWithEditsSource
rather than inOsmQuestController
.Rather than making it really complicated for edge cases to deal with possible parallelism in
onReplacedForBBox
, I made it so that it cannot be executed in parallel. This doesn't change anything for the current configuration because OSM downloads can not happen in parallel (and it is very unlikely that this is ever changed).Note that while testing this solution, I noticed that I could not reproduce the issue in the first place. This was because
Listeners.kt
replaced the previousCopyOnWriteArrayList
-based listeners andListeners
just synchronizes all access:I.e. any
Listeners.forEach(action)
was synchronized, meaning that a parallellisteners.forEach { it.onReplacedForBBox(bbox, mapDataWithGeometry) }
after map data download which triggers creating anew the quests for the downloaded map data and
listeners.forEach { it.onUpdated(updated, deleted) }
after a single update of the data via an edit which triggers checking quests for just that one quest was not possible anymore. They were always executed in order.
So, when trying to solve a quest while the osm data is being updated (=the quests are created), the UI would just seemingly freeze. Argh! The very thing I wanted to avoid. I fixed this now, I hope my fix is fine. Second or third pair of eyes appreciated.