diff --git a/portcontrol.cpp b/portcontrol.cpp --- a/portcontrol.cpp +++ b/portcontrol.cpp @@ -211,9 +211,16 @@ void PortControl::togglePort() } else { - // port name may contain description - QString portName = ui->cbPortList->currentText().split(" ")[0]; - keepPortName(portName); + // we get the port name from the edit text, which may not be + // in the portList if user hasn't pressed Enter + QString portName = ui->cbPortList->currentText(); + int portIndex = portList.indexOf(portName); + if (portIndex < 0) // not in list, add to model and update the selections + { + portList.appendRow(new PortListItem(portName)); + ui->cbPortList->setCurrentIndex(portList.rowCount()-1); + tbPortList.setCurrentIndex(portList.rowCount()-1); + } serialPort->setPortName(portName);