From 115693ea4247a6d7ed5cea85564e40f23c8fffaa Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Wed, 1 Apr 2015 11:19:03 -0700 Subject: [PATCH] More careful about checking for null serial port --- PrinterCommunication/PrinterConnectionAndCommunication.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/PrinterCommunication/PrinterConnectionAndCommunication.cs b/PrinterCommunication/PrinterConnectionAndCommunication.cs index c4a911b76..c40f724ee 100644 --- a/PrinterCommunication/PrinterConnectionAndCommunication.cs +++ b/PrinterCommunication/PrinterConnectionAndCommunication.cs @@ -2117,8 +2117,11 @@ namespace MatterHackers.MatterControl.PrinterCommunication CommunicationState = CommunicationStates.Disconnecting; ReadThreadHolder.Join(); - serialPort.Close(); - serialPort.Dispose(); + if (serialPort != null) + { + serialPort.Close(); + serialPort.Dispose(); + } serialPort = null; CommunicationState = CommunicationStates.Disconnected; LinesToWriteQueue.Clear();