Skip to content

Commit

Permalink
fix: Don't crash if there's no serial ports
Browse files Browse the repository at this point in the history
I have a hardware RS232 port, so always had one COM port
to add to the list of ports that might have been nogasms.
If you had no ports, the application would crash on start.

Fixes #11
  • Loading branch information
blackspherefollower committed Nov 9, 2020
1 parent cdafc1a commit 9435723
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion NogasmChart/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,16 @@ public MainWindow()

MenuFileSave.IsEnabled = false;

ComPort.SelectedItem = SerialPort.GetPortNames()[0];
if (SerialPort.GetPortNames().Any())
{
ComPort.SelectedItem = SerialPort.GetPortNames()[0];
}
else
{
ComPort.IsEnabled = false;
StartStop.IsEnabled = false;
Orgasm.IsEnabled = false;
}

// ToDo: Make this selectable
_analyser = new NogasmMotorDirectAnalyser();
Expand Down

0 comments on commit 9435723

Please sign in to comment.