From d4f52311f7cf335a9bc9e2f6746d4fadc9a99bdf Mon Sep 17 00:00:00 2001 From: Collin Kidder Date: Tue, 19 Feb 2019 21:19:51 -0500 Subject: [PATCH] Fix to correct a few places where 2 buses were hard coded as the limit. There is no hard and fast limit to the number of buses you can have now. --- dbc/dbchandler.cpp | 4 +++- dbc/dbcloadsavewindow.cpp | 4 +++- framesenderwindow.cpp | 8 +++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/dbc/dbchandler.cpp b/dbc/dbchandler.cpp index 3a86bb0..dbd33ac 100644 --- a/dbc/dbchandler.cpp +++ b/dbc/dbchandler.cpp @@ -8,6 +8,7 @@ #include #include #include "utility.h" +#include "connections/canconmanager.h" DBCHandler* DBCHandler::instance = nullptr; @@ -291,8 +292,9 @@ int DBCFile::getAssocBus() void DBCFile::setAssocBus(int bus) { + int numBuses = CANConManager::getInstance()->getNumBuses(); if (bus < -1) return; - if (bus > 1) return; + if (bus >= numBuses) return; assocBuses = bus; } diff --git a/dbc/dbcloadsavewindow.cpp b/dbc/dbcloadsavewindow.cpp index 5853b66..e4dcb5c 100644 --- a/dbc/dbcloadsavewindow.cpp +++ b/dbc/dbcloadsavewindow.cpp @@ -2,6 +2,7 @@ #include "ui_dbcloadsavewindow.h" #include #include "helpwindow.h" +#include "connections/canconmanager.h" DBCLoadSaveWindow::DBCLoadSaveWindow(const QVector *frames, QWidget *parent) : QDialog(parent), @@ -162,7 +163,8 @@ void DBCLoadSaveWindow::cellChanged(int row, int col) { DBCFile *file = dbcHandler->getFileByIdx(row); int bus = ui->tableFiles->item(row, col)->text().toInt(); - if (bus > -2 && bus < 2) + int numBuses = CANConManager::getInstance()->getNumBuses(); + if (bus > -2 && bus < numBuses) { file->setAssocBus(bus); } diff --git a/framesenderwindow.cpp b/framesenderwindow.cpp index 3b0c783..54ab529 100644 --- a/framesenderwindow.cpp +++ b/framesenderwindow.cpp @@ -820,6 +820,8 @@ void FrameSenderWindow::processCellChange(int line, int col) sendingData[line].count = 0; + int numBuses = CANConManager::getInstance()->getNumBuses(); + switch (col) { case 0: //Enable check box @@ -831,9 +833,9 @@ void FrameSenderWindow::processCellChange(int line, int col) qDebug() << "Setting enabled to " << sendingData[line].enabled; break; case 1: //Bus designation - tempVal = Utility::ParseStringToNum(ui->tableSender->item(line, 1)->text()); - if (tempVal < 0) tempVal = 0; - if (tempVal > 1) tempVal = 1; + tempVal = Utility::ParseStringToNum(ui->tableSender->item(line, 1)->text()); + if (tempVal < -1) tempVal = -1; + if (tempVal >= numBuses) tempVal = numBuses - 1; sendingData[line].bus = tempVal; qDebug() << "Setting bus to " << tempVal; break;