Commit f68be0ca authored by Don Gagne's avatar Don Gagne

result used initialized at end of function based on if conditions

Fixing -Wuninitialized
parent 06c36b8b
......@@ -136,29 +136,26 @@ void APMToolBar::connectMAV()
{
qDebug() << "APMToolBar: connectMAV ";
bool connected = false;
if (LinkManager::instance()->getSerialLinks().count() > 0)
connected = LinkManager::instance()->getSerialLinks().last()->isConnected();
bool result;
if (!connected && LinkManager::instance()->getSerialLinks().count() == 0)
{
if (LinkManager::instance()->getSerialLinks().count() > 0) {
bool result;
bool connected = LinkManager::instance()->getSerialLinks().last()->isConnected();
if (connected) {
// result need to be the opposite of success.
result = !LinkManager::instance()->getSerialLinks().last()->disconnect();
} else {
// Need to Connect Link
result = LinkManager::instance()->getSerialLinks().last()->connect();
}
qDebug() << "result = " << result;
// Change the image to represent the state
setConnection(result);
emit MAVConnected(result);
} else {
// No Link so prompt to connect one
MainWindow::instance()->addLink();
} else if (!connected) {
// Need to Connect Link
result = LinkManager::instance()->getSerialLinks().last()->connect();
} else if (connected && LinkManager::instance()->getSerialLinks().count() > 0) {
// result need to be the opposite of success.
result = !LinkManager::instance()->getSerialLinks().last()->disconnect();
}
qDebug() << "result = " << result;
// Change the image to represent the state
setConnection(result);
emit MAVConnected(result);
}
void APMToolBar::setConnection(bool connection)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment