From a1923f132b7671a641731262f428341488f57b7f Mon Sep 17 00:00:00 2001 From: Collin Kidder Date: Sun, 23 May 2021 10:52:23 -0400 Subject: [PATCH] Fixed crash with adding DBC signals, slight code change for clarity in DBC code --- dbc/dbchandler.cpp | 8 ++++---- dbc/dbcmaineditor.cpp | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/dbc/dbchandler.cpp b/dbc/dbchandler.cpp index f3afa53..07a5bae 100644 --- a/dbc/dbchandler.cpp +++ b/dbc/dbchandler.cpp @@ -451,7 +451,7 @@ DBC_SIGNAL* DBCFile::parseSignalLine(QString line, DBC_MESSAGE *msg) QRegularExpressionMatch match; int offset = 0; - bool isMultiplexor = false; + bool isMessageMultiplexor = false; //bool isMultiplexed = false; DBC_SIGNAL sig; @@ -467,7 +467,7 @@ DBC_SIGNAL* DBCFile::parseSignalLine(QString line, DBC_MESSAGE *msg) if (match.hasMatch()) { qDebug() << "Multiplexor signal"; - isMultiplexor = true; + isMessageMultiplexor = true; sig.isMultiplexor = true; } else @@ -490,7 +490,7 @@ DBC_SIGNAL* DBCFile::parseSignalLine(QString line, DBC_MESSAGE *msg) if (match.hasMatch()) { qDebug() << "Extended Multiplexor Signal"; - sig.isMultiplexor = true; //we don't set the local isMultiplexor variable because this isn't the top level multiplexor + sig.isMultiplexor = true; //we don't set the local isMessageMultiplexor variable because this isn't the top level multiplexor sig.isMultiplexed = true; //but, it is both a multiplexor and multiplexed sig.multiplexLowValue = match.captured(2).toInt(); sig.multiplexHighValue = sig.multiplexLowValue; @@ -575,7 +575,7 @@ DBC_SIGNAL* DBCFile::parseSignalLine(QString line, DBC_MESSAGE *msg) if (msg) { msg->sigHandler->addSignal(sig); - if (isMultiplexor) msg->multiplexorSignal = msg->sigHandler->findSignalByName(sig.name); + if (isMessageMultiplexor) msg->multiplexorSignal = msg->sigHandler->findSignalByName(sig.name); return msg->sigHandler->findSignalByName(sig.name); } else return nullptr; diff --git a/dbc/dbcmaineditor.cpp b/dbc/dbcmaineditor.cpp index 571956a..b04019b 100644 --- a/dbc/dbcmaineditor.cpp +++ b/dbc/dbcmaineditor.cpp @@ -602,6 +602,7 @@ void DBCMainEditor::newSignal() } sig.parentMessage = msg; + if (!sig.receiver) sig.receiver = &dbcFile->dbc_nodes[0]; //if receiver not set then set it to... something. msg->sigHandler->addSignal(sig); sigPtr = msg->sigHandler->findSignalByIdx(msg->sigHandler->getCount() - 1); QTreeWidgetItem *newSigItem = new QTreeWidgetItem();