From 9435723609c61d9c130fa927393e685acf538e32 Mon Sep 17 00:00:00 2001 From: blackspherefollower Date: Mon, 9 Nov 2020 05:22:35 -0800 Subject: [PATCH] fix: Don't crash if there's no serial ports 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 --- NogasmChart/MainWindow.xaml.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/NogasmChart/MainWindow.xaml.cs b/NogasmChart/MainWindow.xaml.cs index 7850a7c..8199d2c 100644 --- a/NogasmChart/MainWindow.xaml.cs +++ b/NogasmChart/MainWindow.xaml.cs @@ -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();