1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 07:32:55 +08:00

Merge pull request #9614 from peppy/fix-null-notification

Fix hard crash on notifications firing before NotificationOverlay is ready
This commit is contained in:
Dan Balasescu 2020-07-20 14:04:26 +09:00 committed by GitHub
commit aa6b070418
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -63,7 +63,8 @@ namespace osu.Game
private ChannelManager channelManager; private ChannelManager channelManager;
private NotificationOverlay notifications; [NotNull]
private readonly NotificationOverlay notifications = new NotificationOverlay();
private NowPlayingOverlay nowPlaying; private NowPlayingOverlay nowPlaying;
@ -82,7 +83,7 @@ namespace osu.Game
public virtual Storage GetStorageForStableInstall() => null; public virtual Storage GetStorageForStableInstall() => null;
public float ToolbarOffset => Toolbar.Position.Y + Toolbar.DrawHeight; public float ToolbarOffset => (Toolbar?.Position.Y ?? 0) + (Toolbar?.DrawHeight ?? 0);
private IdleTracker idleTracker; private IdleTracker idleTracker;
@ -250,7 +251,7 @@ namespace osu.Game
case LinkAction.OpenEditorTimestamp: case LinkAction.OpenEditorTimestamp:
case LinkAction.JoinMultiplayerMatch: case LinkAction.JoinMultiplayerMatch:
case LinkAction.Spectate: case LinkAction.Spectate:
waitForReady(() => notifications, _ => notifications?.Post(new SimpleNotification waitForReady(() => notifications, _ => notifications.Post(new SimpleNotification
{ {
Text = @"This link type is not yet supported!", Text = @"This link type is not yet supported!",
Icon = FontAwesome.Solid.LifeRing, Icon = FontAwesome.Solid.LifeRing,
@ -536,14 +537,14 @@ namespace osu.Game
MenuCursorContainer.CanShowCursor = menuScreen?.CursorVisible ?? false; MenuCursorContainer.CanShowCursor = menuScreen?.CursorVisible ?? false;
// todo: all archive managers should be able to be looped here. // todo: all archive managers should be able to be looped here.
SkinManager.PostNotification = n => notifications?.Post(n); SkinManager.PostNotification = n => notifications.Post(n);
SkinManager.GetStableStorage = GetStorageForStableInstall; SkinManager.GetStableStorage = GetStorageForStableInstall;
BeatmapManager.PostNotification = n => notifications?.Post(n); BeatmapManager.PostNotification = n => notifications.Post(n);
BeatmapManager.GetStableStorage = GetStorageForStableInstall; BeatmapManager.GetStableStorage = GetStorageForStableInstall;
BeatmapManager.PresentImport = items => PresentBeatmap(items.First()); BeatmapManager.PresentImport = items => PresentBeatmap(items.First());
ScoreManager.PostNotification = n => notifications?.Post(n); ScoreManager.PostNotification = n => notifications.Post(n);
ScoreManager.GetStableStorage = GetStorageForStableInstall; ScoreManager.GetStableStorage = GetStorageForStableInstall;
ScoreManager.PresentImport = items => PresentScore(items.First()); ScoreManager.PresentImport = items => PresentScore(items.First());
@ -615,12 +616,12 @@ namespace osu.Game
loadComponentSingleFile(MusicController = new MusicController(), Add, true); loadComponentSingleFile(MusicController = new MusicController(), Add, true);
loadComponentSingleFile(notifications = new NotificationOverlay loadComponentSingleFile(notifications.With(d =>
{ {
GetToolbarHeight = () => ToolbarOffset, d.GetToolbarHeight = () => ToolbarOffset;
Anchor = Anchor.TopRight, d.Anchor = Anchor.TopRight;
Origin = Anchor.TopRight, d.Origin = Anchor.TopRight;
}, rightFloatingOverlayContent.Add, true); }), rightFloatingOverlayContent.Add, true);
loadComponentSingleFile(screenshotManager, Add); loadComponentSingleFile(screenshotManager, Add);