From 591ebe71df7df5c116145b2b5596c7b107fc5db3 Mon Sep 17 00:00:00 2001 From: Collin Kidder Date: Wed, 6 Mar 2019 20:20:40 -0500 Subject: [PATCH] Fixes to debug console in connection window --- connections/connectionwindow.cpp | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/connections/connectionwindow.cpp b/connections/connectionwindow.cpp index 5ab3f69..0c2faea 100644 --- a/connections/connectionwindow.cpp +++ b/connections/connectionwindow.cpp @@ -167,18 +167,20 @@ void ConnectionWindow::consoleEnableChanged(bool checked) { ui->btnSendText->setEnabled(checked); ui->lineSend->setEnabled(checked); - QList& conns = CANConManager::getInstance()->getConnections(); + int selIdx = ui->tableConnections->currentIndex().row(); - foreach(CANConnection* conn_p, conns) - { - if (checked) { //enable console - connect(conn_p, SIGNAL(debugOutput(QString)), this, SLOT(getDebugText(QString))); - connect(this, SIGNAL(sendDebugData(QByteArray)), conn_p, SLOT(debugInput(QByteArray))); - } - else { //turn it off - disconnect(conn_p, SIGNAL(debugOutput(QString)), nullptr, nullptr); - disconnect(this, SIGNAL(sendDebugData(QByteArray)), conn_p, SLOT(debugInput(QByteArray))); - } + if (selIdx == -1) + return; + + CANConnection* conn_p = connModel->getAtIdx(selIdx); + + if (checked) { //enable console + connect(conn_p, SIGNAL(debugOutput(QString)), this, SLOT(getDebugText(QString))); + connect(this, SIGNAL(sendDebugData(QByteArray)), conn_p, SLOT(debugInput(QByteArray))); + } + else { //turn it off + disconnect(conn_p, SIGNAL(debugOutput(QString)), nullptr, nullptr); + disconnect(this, SIGNAL(sendDebugData(QByteArray)), conn_p, SLOT(debugInput(QByteArray))); } } @@ -315,6 +317,11 @@ void ConnectionWindow::currentRowChanged(const QModelIndex ¤t, const QMode if (numBuses > 1) for (int i = 0; i < numBuses; i++) ui->tabBuses->addTab(QString::number(i+1)); populateBusDetails(0); + if (ui->ckEnableConsole->isChecked()) + { + connect(conn_p, SIGNAL(debugOutput(QString)), this, SLOT(getDebugText(QString))); + connect(this, SIGNAL(sendDebugData(QByteArray)), conn_p, SLOT(debugInput(QByteArray))); + } } }