mirror of
https://github.com/nymea/nymea-plugins.git
synced 2026-10-24 14:55:39 +02:00
added pointer checks
This commit is contained in:
parent
fe37c50ff9
commit
53c9759439
@ -305,9 +305,11 @@ void DevicePluginWs2812fx::deviceRemoved(Device *device)
|
|||||||
|
|
||||||
m_usedInterfaces.removeAll(device->paramValue(ws2812fxDeviceSerialPortParamTypeId).toString());
|
m_usedInterfaces.removeAll(device->paramValue(ws2812fxDeviceSerialPortParamTypeId).toString());
|
||||||
QSerialPort *serialPort = m_serialPorts.take(device);
|
QSerialPort *serialPort = m_serialPorts.take(device);
|
||||||
serialPort->flush();
|
if(serialPort) {
|
||||||
serialPort->close();
|
serialPort->flush();
|
||||||
serialPort->deleteLater();
|
serialPort->close();
|
||||||
|
serialPort->deleteLater();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (myDevices().empty()) {
|
if (myDevices().empty()) {
|
||||||
@ -320,6 +322,8 @@ void DevicePluginWs2812fx::onReadyRead()
|
|||||||
{
|
{
|
||||||
QSerialPort *serialPort = static_cast<QSerialPort*>(sender());
|
QSerialPort *serialPort = static_cast<QSerialPort*>(sender());
|
||||||
Device *device = m_serialPorts.key(serialPort);
|
Device *device = m_serialPorts.key(serialPort);
|
||||||
|
if (!device)
|
||||||
|
return;
|
||||||
|
|
||||||
QByteArray data;
|
QByteArray data;
|
||||||
while (serialPort->canReadLine()) {
|
while (serialPort->canReadLine()) {
|
||||||
@ -402,6 +406,8 @@ void DevicePluginWs2812fx::onSerialError(QSerialPort::SerialPortError error)
|
|||||||
{
|
{
|
||||||
QSerialPort *serialPort = static_cast<QSerialPort*>(sender());
|
QSerialPort *serialPort = static_cast<QSerialPort*>(sender());
|
||||||
Device *device = m_serialPorts.key(serialPort);
|
Device *device = m_serialPorts.key(serialPort);
|
||||||
|
if (!device)
|
||||||
|
return;
|
||||||
|
|
||||||
if (error != QSerialPort::NoError && serialPort->isOpen()) {
|
if (error != QSerialPort::NoError && serialPort->isOpen()) {
|
||||||
qCCritical(dcWs2812fx()) << "Serial port error:" << error << serialPort->errorString();
|
qCCritical(dcWs2812fx()) << "Serial port error:" << error << serialPort->errorString();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user