From c398856806a9c1287abb46299e6f8aef9a6ec6d9 Mon Sep 17 00:00:00 2001 From: Collin Kidder Date: Thu, 9 Nov 2017 20:07:00 -0500 Subject: [PATCH] Small fix to make unconnected devices still show up properly in the connection window --- connections/canconnectionmodel.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/connections/canconnectionmodel.cpp b/connections/canconnectionmodel.cpp index f68b9d0..a63c508 100644 --- a/connections/canconnectionmodel.cpp +++ b/connections/canconnectionmodel.cpp @@ -151,16 +151,13 @@ QVariant CANConnectionModel::data(const QModelIndex &index, int role) const CANConnection *conn_p = getAtIdx(index.row(), busId); CANBus bus; bool ret; + if (!conn_p) return QVariant(); ret = conn_p->getBusSettings(busId, bus); bool isSocketCAN = (conn_p->getType() == CANCon::SOCKETCAN) ? true: false; //qDebug() << "ConnP: " << conn_p << " ret " << ret; - if (role == Qt::DisplayRole) { - if(!conn_p) - return QVariant(); - - if(!ret) return QVariant(); + if (role == Qt::DisplayRole) { switch (index.column()) { @@ -183,6 +180,7 @@ QVariant CANConnectionModel::data(const QModelIndex &index, int role) const else qDebug() << "Tried to show connection port but connection was NULL"; break; case 3: //speed + if(!ret) return QVariant(); if (!isSocketCAN) return QString::number(bus.speed); else return QString("N/A"); case 4: //Listen Only