1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 19:27:24 +08:00

Merge pull request #21071 from peppy/fix-multiple-import-notifications

Fix multiple notifications arriving for imports in edge cases
This commit is contained in:
Dan Balasescu 2022-11-02 16:54:56 +09:00 committed by GitHub
commit cb51fc7384
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -148,7 +148,7 @@ namespace osu.Game.Overlays.Notifications
} }
} }
private bool completionSent; private int completionSent;
/// <summary> /// <summary>
/// Attempt to post a completion notification. /// Attempt to post a completion notification.
@ -162,11 +162,11 @@ namespace osu.Game.Overlays.Notifications
if (CompletionTarget == null) if (CompletionTarget == null)
return; return;
if (completionSent) // Thread-safe barrier, as this may be called by a web request and also scheduled to the update thread at the same time.
if (Interlocked.Exchange(ref completionSent, 1) == 1)
return; return;
CompletionTarget.Invoke(CreateCompletionNotification()); CompletionTarget.Invoke(CreateCompletionNotification());
completionSent = true;
Close(false); Close(false);
} }