Fix automatic loading of connections on start up. Shouldn't crash
now...
This commit is contained in:
@@ -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]);
|
||||
|
||||
@@ -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
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user