Fix bugs in DBC editor

This commit is contained in:
Collin Kidder
2015-07-20 23:07:46 -04:00
parent 10fc01f15e
commit b3e8562a45
+17 -10
View File
@@ -204,6 +204,8 @@ void DBCMainEditor::onCellChangedMessage(int row,int col)
{ {
if (inhibitCellChanged) return; if (inhibitCellChanged) return;
qDebug() << "Editing row: " << row << " col: " << col;
QTableWidgetItem *replacement = NULL; QTableWidgetItem *replacement = NULL;
int msgID; int msgID;
QString msgName; QString msgName;
@@ -211,12 +213,21 @@ void DBCMainEditor::onCellChangedMessage(int row,int col)
QString msgComment; QString msgComment;
DBC_MESSAGE newMsg; DBC_MESSAGE newMsg;
DBC_NODE *node = dbcHandler->findNodeByIdx(ui->NodesTable->currentRow()); DBC_NODE *node = dbcHandler->findNodeByIdx(ui->NodesTable->currentRow());
if (node == NULL) dbcHandler->findNodeByIdx(0); DBC_MESSAGE *msg;
if (node == NULL)
{
qDebug() << "No node set?!? This is bad!";
return;
//dbcHandler->findNodeByIdx(0);
}
msgID = ui->MessagesTable->item(row, 0)->text().toInt(NULL, 16);
qDebug() << "Msg ID of edited: " << msgID;
msg = dbcHandler->findMsgByID(msgID);
switch(col) switch(col)
{ {
case 0: //msg id case 0: //msg id
msgID = ui->MessagesTable->item(row, col)->text().toInt(NULL, 16);
if (row == ui->MessagesTable->rowCount() - 1) //new record if (row == ui->MessagesTable->rowCount() - 1) //new record
{ {
if (dbcHandler->findMsgByID(msgID) != NULL) if (dbcHandler->findMsgByID(msgID) != NULL)
@@ -243,8 +254,7 @@ void DBCMainEditor::onCellChangedMessage(int row,int col)
} }
else //editing an existing record else //editing an existing record
{ {
DBC_MESSAGE *msg = dbcHandler->findMsgByIdx(row); if (msg != NULL) msg->ID = msgID;
msg->ID = msgID;
} }
inhibitCellChanged = true; inhibitCellChanged = true;
replacement = new QTableWidgetItem(QString::number(msgID, 16)); replacement = new QTableWidgetItem(QString::number(msgID, 16));
@@ -274,8 +284,7 @@ void DBCMainEditor::onCellChangedMessage(int row,int col)
} }
else else
{ {
DBC_MESSAGE *msg = dbcHandler->findMsgByIdx(row); if (msg != NULL) msg->name = msgName;
msg->name = msgName;
} }
inhibitCellChanged = true; inhibitCellChanged = true;
replacement = new QTableWidgetItem(msgName); replacement = new QTableWidgetItem(msgName);
@@ -298,8 +307,7 @@ void DBCMainEditor::onCellChangedMessage(int row,int col)
} }
else //editing an existing record else //editing an existing record
{ {
DBC_MESSAGE *msg = dbcHandler->findMsgByIdx(row); if (msg != NULL) msg->len = msgLen;
msg->len = msgLen;
} }
inhibitCellChanged = true; inhibitCellChanged = true;
replacement = new QTableWidgetItem(QString::number(msgLen, 16)); replacement = new QTableWidgetItem(QString::number(msgLen, 16));
@@ -323,8 +331,7 @@ void DBCMainEditor::onCellChangedMessage(int row,int col)
} }
else //editing an existing record else //editing an existing record
{ {
DBC_MESSAGE *msg = dbcHandler->findMsgByIdx(row); if (msg != NULL) msg->comment = msgComment;
msg->comment = msgComment;
} }
inhibitCellChanged = true; inhibitCellChanged = true;
replacement = new QTableWidgetItem(msgComment); replacement = new QTableWidgetItem(msgComment);