Commit 3e0cd207 authored by Lorenz Meier's avatar Lorenz Meier

Use a local variable for the port list, use correct null ptr macro

parent 252b70de
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
SerialLink::SerialLink(QString portname, int baudRate, bool hardwareFlowControl, bool parity, SerialLink::SerialLink(QString portname, int baudRate, bool hardwareFlowControl, bool parity,
int dataBits, int stopBits) : int dataBits, int stopBits) :
m_bytesRead(0), m_bytesRead(0),
m_port(NULL), m_port(Q_NULLPTR),
type(""), type(""),
m_is_cdc(true), m_is_cdc(true),
m_stopp(false), m_stopp(false),
...@@ -34,9 +34,10 @@ SerialLink::SerialLink(QString portname, int baudRate, bool hardwareFlowControl, ...@@ -34,9 +34,10 @@ SerialLink::SerialLink(QString portname, int baudRate, bool hardwareFlowControl,
// Get the name of the current port in use. // Get the name of the current port in use.
m_portName = portname.trimmed(); m_portName = portname.trimmed();
if (m_portName == "" && getCurrentPorts().size() > 0) QList<QString> ports = getCurrentPorts();
if (m_portName == "" && ports.size() > 0)
{ {
m_portName = m_ports.first().trimmed(); m_portName = ports.first().trimmed();
} }
checkIfCDC(); checkIfCDC();
...@@ -96,15 +97,15 @@ SerialLink::~SerialLink() ...@@ -96,15 +97,15 @@ SerialLink::~SerialLink()
QList<QString> SerialLink::getCurrentPorts() QList<QString> SerialLink::getCurrentPorts()
{ {
m_ports.clear(); QList<QString> ports;
QList<QSerialPortInfo> portList = QSerialPortInfo::availablePorts(); QList<QSerialPortInfo> portList = QSerialPortInfo::availablePorts();
foreach (const QSerialPortInfo &info, portList) foreach (const QSerialPortInfo &info, portList)
{ {
m_ports.append(info.portName()); ports.append(info.portName());
} }
return m_ports; return ports;
} }
bool SerialLink::isBootloader() bool SerialLink::isBootloader()
......
...@@ -158,7 +158,6 @@ protected: ...@@ -158,7 +158,6 @@ protected:
int m_id; int m_id;
QMutex m_dataMutex; // Mutex for reading data from m_port QMutex m_dataMutex; // Mutex for reading data from m_port
QMutex m_writeMutex; // Mutex for accessing the m_transmitBuffer. QMutex m_writeMutex; // Mutex for accessing the m_transmitBuffer.
QList<QString> m_ports;
QString type; QString type;
bool m_is_cdc; bool m_is_cdc;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment