From 4e29541c795ec4d458992d67d8e2f0509e0e67fe Mon Sep 17 00:00:00 2001 From: Bill Bonney Date: Wed, 31 Jul 2013 12:52:43 -0700 Subject: [PATCH] Fixed the accidental removal of UDP listening of startup --- src/QGCCore.cc | 22 ++++++++++++++++++++++ src/comm/UDPLink.cc | 3 ++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/QGCCore.cc b/src/QGCCore.cc index ee0e4ef81..e5817082a 100644 --- a/src/QGCCore.cc +++ b/src/QGCCore.cc @@ -171,6 +171,28 @@ QGCCore::QGCCore(int &argc, char* argv[]) : QApplication(argc, argv) if (upgraded) mainWindow->showInfoMessage(tr("Default Settings Loaded"), tr("APM Planner has been upgraded from version %1 to version %2. Some of your user preferences have been reset to defaults for safety reasons. Please adjust them where needed.").arg(lastApplicationVersion).arg(QGC_APPLICATION_VERSION)); + // Check if link could be connected + if (!udpLink->connect()) + { + QMessageBox msgBox; + msgBox.setIcon(QMessageBox::Critical); + msgBox.setText("Could not connect UDP port. Is an instance of " + qAppName() + "already running?"); + msgBox.setInformativeText("You will not be able to receive data via UDP. Please check that you're running the right executable and then re-start " + qAppName() + ". Do you want to close the application?"); + msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + msgBox.setDefaultButton(QMessageBox::No); + int ret = msgBox.exec(); + + // Close the message box shortly after the click to prevent accidental clicks + QTimer::singleShot(15000, &msgBox, SLOT(reject())); + + // Exit application + if (ret == QMessageBox::Yes) + { + //mainWindow->close(); + QTimer::singleShot(200, mainWindow, SLOT(close())); + } + } + } /** diff --git a/src/comm/UDPLink.cc b/src/comm/UDPLink.cc index 708de75b8..0cade2786 100644 --- a/src/comm/UDPLink.cc +++ b/src/comm/UDPLink.cc @@ -50,6 +50,7 @@ UDPLink::UDPLink(QHostAddress host, quint16 port) this->name = tr("UDP Link (port:%1)").arg(this->port); emit nameChanged(this->name); // LinkManager::instance()->add(this); + qDebug() << "UDP Created " << name; } UDPLink::~UDPLink() @@ -104,7 +105,7 @@ void UDPLink::setPort(int port) */ void UDPLink::addHost(const QString& host) { - //qDebug() << "UDP:" << "ADDING HOST:" << host; + qDebug() << "UDP:" << "ADDING HOST:" << host; if (host.contains(":")) { //qDebug() << "HOST: " << host.split(":").first(); -- 2.22.0