Skip to content

Commit f46d0ce

Browse files
committed
Null checking
1 parent c2ef38e commit f46d0ce

3 files changed

Lines changed: 15 additions & 7 deletions

File tree

src/Avalon.Client/HashCommands/Beep.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,19 @@ public override void Execute()
4343
switch (o.BeepType)
4444
{
4545
case BeepType.Beep:
46-
SystemSounds.Beep.Play();
46+
SystemSounds.Beep?.Play();
4747
return;
4848
case BeepType.Asterisk:
49-
SystemSounds.Asterisk.Play();
49+
SystemSounds.Asterisk?.Play();
5050
return;
5151
case BeepType.Exclamation:
52-
SystemSounds.Exclamation.Play();
52+
SystemSounds.Exclamation?.Play();
5353
return;
5454
case BeepType.Hand:
55-
SystemSounds.Hand.Play();
55+
SystemSounds.Hand?.Play();
5656
return;
5757
case BeepType.Question:
58-
SystemSounds.Question.Play();
58+
SystemSounds.Question?.Play();
5959
return;
6060
case BeepType.Alert:
6161
// Special type, this will play even if other system sounds are muted.

src/Avalon.Client/HashCommands/ToastAlarm.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public ToastAlarm(IInterpreter interp) : base(interp)
2929

3030
public override void Execute()
3131
{
32-
SystemSounds.Exclamation.Play();
32+
SystemSounds.Exclamation?.Play();
3333
App.Toast.ShowNotification("Avalon", this.Parameters, ToolTipIcon.Warning);
3434
}
3535

src/Avalon.Client/MainWindow.Network.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* @license : MIT
88
*/
99

10+
using System.Media;
1011
using Avalon.Colors;
1112
using Avalon.Common.Models;
1213
using Avalon.Controls;
@@ -139,7 +140,14 @@ public void HandleLineReceived(object sender, string e)
139140
// One beep per line max, everything else is ignored.
140141
if (App.Settings.ProfileSettings.AnsiBeep && e.Contains('\a'))
141142
{
142-
App.Beep?.Play();
143+
if (App.Beep != null)
144+
{
145+
App.Beep.Play();
146+
}
147+
else
148+
{
149+
SystemSounds.Beep?.Play();
150+
}
143151
}
144152

145153
try

0 commit comments

Comments
 (0)