From 83fb042e92f0c454b6990595c571500b7f998dae Mon Sep 17 00:00:00 2001 From: Collin Kidder Date: Tue, 1 Aug 2023 21:37:59 -0400 Subject: [PATCH] Fixed issue where making a new message could create that message with an already existing ID. Fixed issue where creating a new signal from an existing signal would not show up properly. --- dbc/dbcmaineditor.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/dbc/dbcmaineditor.cpp b/dbc/dbcmaineditor.cpp index 5e42d9c..30275c6 100644 --- a/dbc/dbcmaineditor.cpp +++ b/dbc/dbcmaineditor.cpp @@ -693,8 +693,14 @@ void DBCMainEditor::newMessage() DBC_MESSAGE *oldMsg = dbcFile->messageHandler->findMsgByID(msgID); if (oldMsg) { - msg.name = oldMsg->name + QString::number(randGen.bounded(1000)); + msg.name = "Msg" + QString::number(randGen.bounded(500)); msg.ID = oldMsg->ID + 1; + DBC_MESSAGE *overlappedMsg = dbcFile->messageHandler->findMsgByID(msg.ID); + while (overlappedMsg) + { + msg.ID++; + overlappedMsg = dbcFile->messageHandler->findMsgByID(msg.ID); + } msg.len = oldMsg->len; msg.bgColor = oldMsg->bgColor; msg.fgColor = oldMsg->fgColor; @@ -783,8 +789,7 @@ void DBCMainEditor::newSignal() msg->sigHandler->addSignal(sig); sigPtr = msg->sigHandler->findSignalByIdx(msg->sigHandler->getCount() - 1); QTreeWidgetItem *newSigItem = new QTreeWidgetItem(); - QString sigInfo = sig.name; - if (sig.comment.count() > 0) sigInfo.append(" - ").append(sig.comment); + QString sigInfo = createSignalText(&sig); newSigItem->setText(0, sigInfo); if (sig.isMultiplexed) newSigItem->setIcon(0, multiplexedSignalIcon); else if (sig.isMultiplexor) newSigItem->setIcon(0, multiplexorSignalIcon);