Fix automatic loading of connections on start up. Shouldn't crash

now...
This commit is contained in:
Collin Kidder
2019-02-17 15:15:48 -05:00
parent f6269dd5f4
commit 3291869849
3 changed files with 12 additions and 4 deletions
+4 -1
View File
@@ -42,7 +42,7 @@ ConnectionWindow::ConnectionWindow(QWidget *parent) :
ui->lineSend->setEnabled(false);
/* load connection configuration */
//loadConnections();
loadConnections();
ui->rbSocketCAN->setEnabled(isSerialBusAvailable());
@@ -541,6 +541,9 @@ void ConnectionWindow::loadConnections()
QVector<QString> driverNames = settings.value("connections/driverNames").value<QVector<QString>>();
QVector<int> devTypes = settings.value("connections/types").value<QVector<int>>();
//don't load the connections if the three setting arrays above aren't all the same size.
if (portNames.count() != driverNames.count() || devTypes.count() != driverNames.count()) return;
for(int i = 0 ; i < portNames.count() ; i++)
{
CANConnection* conn_p = create((CANCon::type)devTypes[i], portNames[i], driverNames[i]);
+7 -2
View File
@@ -344,7 +344,7 @@ void GVRetSerial::connectDevice()
serial->setFlowControl(serial->NoFlowControl);
if (!serial->open(QIODevice::ReadWrite))
{
sendDebug("Error returned during port opening: " + serial->errorString());
//sendDebug("Error returned during port opening: " + serial->errorString());
}
else
{
@@ -359,7 +359,7 @@ void GVRetSerial::connectDevice()
serial->setFlowControl(serial->HardwareControl); //Most GVRET style devices use hardware flow control
if (!serial->open(QIODevice::ReadWrite))
{
sendDebug("Error returned during port opening: " + serial->errorString());
//sendDebug("Error returned during port opening: " + serial->errorString());
}
else
{
@@ -473,14 +473,17 @@ void GVRetSerial::serialError(QSerialPort::SerialPortError err)
case QSerialPort::DeviceNotFoundError:
errMessage = "Device not found error on serial";
killConnection = true;
piStop();
break;
case QSerialPort::PermissionError:
errMessage = "Permission error on serial port";
killConnection = true;
piStop();
break;
case QSerialPort::OpenError:
errMessage = "Open error on serial port";
killConnection = true;
piStop();
break;
case QSerialPort::ParityError:
errMessage = "Parity error on serial port";
@@ -500,6 +503,7 @@ void GVRetSerial::serialError(QSerialPort::SerialPortError err)
case QSerialPort::ResourceError:
errMessage = "Serial port seems to have disappeared.";
killConnection = true;
piStop();
break;
case QSerialPort::UnsupportedOperationError:
errMessage = "Unsupported operation on serial port";
@@ -516,6 +520,7 @@ void GVRetSerial::serialError(QSerialPort::SerialPortError err)
case QSerialPort::NotOpenError:
errMessage = "The serial port isn't open";
killConnection = true;
piStop();
break;
}
/*
+1 -1
View File
@@ -184,7 +184,7 @@ MainWindow::MainWindow(QWidget *parent) :
ui->actionFirmware_Update->setVisible(false);
ui->actionMotorControlConfig->setVisible(false);
ui->actionSignal_Viewer->setVisible(false);
//ui->actionSingle_Multi_State_2->setVisible(false);
ui->actionSingle_Multi_State_2->setVisible(false);
installEventFilter(this);
}